How to use a customized directory location for ins

2019-07-30 15:15发布

问题:

I am running Rstudio 0.97 with R 3.0.1 on Windows 8.1. I installed a lot of packages through Rstudio and they all went to "\R\R-3.0.1\library". Now I installed R 3.1.0 and set Rstudio to use the new version of R. But then I found the packages are all inaccessible from Rstudio.

How to make the packages in a shared folder so that the different versions of R on my PC can all use them?

I tried to use .libPaths("XXXX package sharefolder") to set a sharefolder to storing and installing new packages, it works in a session but when I restart Rstudio, the path is reset. Didn't work.

回答1:

First, mkdir ~/whatever-you-want if necessary.

Second, add R_LIBS_USER="~/whatever-you-want" to '~/.Renviron'.

So, if you want to reuse \R\R-3.0.1\library as you mentioned, add R_LIBS_USER="\R\R-3.0.1\library" to your '~/.Renviron'. If you are using Windows, put the .Renviron in C:\Users\<user-name>\.

Hope it helps.



标签: r package