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?
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.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With