horseshoe horseshoe - 1 year ago 140
R Question

R libraries installation

I am using a computer where I have read only rights for the R library folder.
When I am installing new packages I therefore use

libpath <- "c:/R/mylibraries"
.libPaths( c( .libPaths(), libpath) )
install.packages("htmltools", lib=libpath)

always when I am installing a new packages with dependecies (like e.g. htmltools depends on lme4), I get erros like:

Error in .requirePackage(package) :
unable to find required package ‘lme4’

although lme4 is installed and I used it before....
also other errors/warnings like:

Warning in install.packages :
cannot remove prior installation of package ‘Rcpp’


Warning in install.packages :
unable to move temporary installation ‘c:\...\file17b033a54a21\jsonlite’ to ‘c:\...\jsonlite’

occur. If I install them twice they usually work but sometimes dependencies to packages that worked before are lost and I have to reinstall them again.
Is there a way to circumvent this?

Answer Source

Put this in a file named .REnviron in your Documents folder and restart R:


From then on, you should be able to install packages into that location automatically, without having to fiddle around with .libPaths.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download