简体   繁体   中英

Installing R packages on Windows 7

On Windows 7 x64, I've got version 3.0.0 of R installed. Further, I've also set the environment variable R_LIBS_USER to point to a network drive. In rgui.exe, executing:

Sys.getenv("R_LIBS_USER")

outputs the same value that I previously set above. Also from R, installing packages into the personal library pointed to by R_LIBS_USER works fine. So far, so good.

With version 0.97.551 of RStudio installed, executing the same code above through RStudio also outputs the same value (as expected). However, from RStudio, my attempts at installing packages into the personal library fails. The error message effectively states that RStudio is unable to write to the personal library defined by R_LIBS_USER.

Before posting to stackoverflow, I checked the support forum for RStudio ( http://support.rstudio.org/help/discussions/problems/4608-change-personal-library-for-installing-packages ) where an admin states that the problem has to do with R and not RStudio. The admin goes on to reference the RStudio document generated by code

?.libPaths

in the RStudio IDE. The admin also provides additional guidance through link http://support.rstudio.org/help/kb/troubleshooting/getting-help-with-r .

After reviewing the IDE-generated document and forum link, I've determined that my environment is set up correctly. And yet, RStudio still fails.

Has anyone been able to get RStudio personal library working with a filesystem location other than the defaults?

I should clarify my needs a bit more. The environment to which this application will eventually be deployed prohibits normal users from running RStudio as administrators, hence the focus on R_LIBS_USER personal library. So although I know this would work, it is not a realistic option for me.

What I need is for RStudio to exclusively write to R_LIBS_USER and not attempt to also write to R_HOME (my assumption of what I think it is actually attempting to do.)

Add a line .libPaths("~/your-lib-path-here") to your .Rprofile and restart R. .libPaths() lets you write as well as read the the set of default libraries.

Alternately, if you can control the installation commands (ie you need your library to be available but it doesn't have to be the default), most R commands such as install.packages have a lib parameter that lets you manually specify the library to install to.

You might consider using an R package management system such as Packrat , which automates the job of installing your application's dependencies to a private library without you having to set it up manually. (Full disclosure, I'm a contributor to this package.) It works under RStudio.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM