Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

r - How to specify the path in normalizePath, or get around this error associated with it?

Tags:

r

I'm learning R and just have it installed on my office computer. I don't have the administrator right on the computer (as I even have to call IT for installation).

Then I install a package. At first it doesn't work when typing, for example:

install.packages("thepackage")

The error message is this:

Error in normalizePath(path.expand(path), winslash, mustWork) : 
  path[1]="\\company\5050\Users\myusername\Documents\R\win-library\3.3": Access is denied
In addition: Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="\\company/5050/Users/myusername/Documents/R/win-library/3.3": Access is denied

I do some homework and find that a potential solution is to "Map a network drive to your network folder". I'm not sure what it means, but I try this:

install.packages("thepackage",lib="H:/Documents/R/win-library/3.3")

because it looks like I have more "control" of H drive (it has my username on it). And it works:

package ‘thepackage’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
    C:\Users\myusername\AppData\Local\Temp\Rtmp4MNURu\downloaded_packages

I then fail to load the package,

library(thepackage)

saying:

Error in normalizePath(path.expand(path), winslash, mustWork) : 
  path[1]="\\company/5050/Users/myusername/Documents/R/win-library/3.3": Access is denied

But again this works:

library(thepackage,lib="H:/Documents/R/win-library/3.3")

So how can I set the normalizePath to the one that works to avoid additional and rather unnecessary specification of library directory?

like image 961
NonSleeper Avatar asked May 25 '16 06:05

NonSleeper


2 Answers

You can put in your home directory's .Rprofile file (just create it if it's not there yet) the following line:

.libPaths("H:/Documents/R/win-library/3.3")

That way this location will be used by default. The .Rprofile is run every time you're opening any new R session. You can copy the existing content of the folder from which you don't have write access to this folder to include all pre-installed packages.

like image 105
Dominic Comtois Avatar answered Sep 19 '22 12:09

Dominic Comtois


I think you are looking for:

system("net use D: \\\\company\\path\\")

to map to the virtual D drive. I would then use file.path when accessing the stuff on D:. It looks that you may benefit from changing R defalut library path in Rprofile.site, by adding the line:

.libPaths("Path to your libs")

When you type .libPaths() can you read and write to that directory with no problems?

like image 33
Konrad Avatar answered Sep 19 '22 12:09

Konrad