The two that matter for storing and accessing packages are (now different on a Linux box): R_LIBS_SITE /usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library Since Sys.getenv() returns the current system environment for the R process, you can see the library and other paths with: Sys.getenv() Library.site, which is further reason why an RStudio- (or any other IDE or network installed-) hosted R might exhibit different behavior. It should also be mentioned that the result from this operation also appends the contents of calls to. Rprofile setting from one of the RStudio defaults.
In your case it appears that RStudio is not respecting the Rprofile.site settings or perhaps is overriding them by reading an. The information about the R startup process can be read at ?Startup help page and there is RStudio material at: libPaths can either report or alter its target. The functions Sys.getenv and Sys.setenv that report and alter the R environment variables have been split apart but. libPaths function is a bit different than most other nongraphics functions. "/Library/Frameworks/R.framework/Versions/2.15/Resources/library" Then I get (at least back when I wrote this originally): >. Or (and this will make the userLibrary the first place to put new packages).
# min just happened to be on a Mac that day # obviously this would need to be a valid file directory in your OS I generally try to keep all of my packages in one library, but if you want to add a library why not append the new library (which must already exist in your filesystem) to the existing library path?. The Rprofile solution does not work when clicking on a file to start RStudio because that changes the working directory away from the default working directory. In this case, setting the default working directory to the directory that houses your Rprofile will be sufficient. The Rprofile solution can work if RStudio is always started by clicking the RStudio shortcut. libPaths() regardless of starting RStudio directly or by right-clicking an file and "Open With" to start RStudio. Setting R_LIBS_USER will ensure that the library shows up first in.
If for some reason you do not have access to the control panel, you can try running rundll32 sysdm.cpl,EditEnvironmentVariables from the command line on Windows and add the environment variable from there. To set environment variable R_LIBS_USER in Windows, go to the Control Panel (System Properties -> Advanced system properties -> Environment Variables -> User Variables) to a desired value (the path to your library folder), e.g. The proper solution is to set environment variable R_LIBS_USER to the value of the file path to your desired library folder as opposed to getting RStudio to recognize a Rprofile.site file. "C:/software/Rpackages" "C:/Program Files/R/R-2.15.2/library" libPaths() command seems to work as it is supposed to.
libPaths command that I added to the Rprofile.site doesn't seem to have had any effect! Why is this the case? Or more importantly, how can I fix the problem so that I can install and load packages without typing in the library location? "C:/Program Files/R/R-2.15.2/library" "C:/Program Files/RStudio/R/library" However, after doing this, and starting RStudio, this is the output that I get >. To load a package, I also have to specify the library location: library("zoo", lib.loc="C:/software/Rpackages")Īll of this is OK, but I wanted to see if I could add C:/software/Rpackages to the library path somehow and thus not have to type it each time.Īs I searched online, I found that one way to do this is to edit the Rprofile.site file and to add the line. To install a package, I have to specify a library location: install.packages("zoo", lib="C:/software/Rpackages")
'lib = "C:/Program Files/R/R-2.15.2/library"' is not writable Installing package(s) into ‘C:/Program Files/R/R-2.15.2/library’ When I install a package, the following command doesn't work: > install.packages("zoo") I am running R on Windows, not as an administrator.