The install.packages() function in R is the automatic unzipping utility that gets and install packages in R.
How do I find out what directory R has chosen to store packages?
How can I change the directory in which R stores and accesses packages?
The install.packages() function in R is the automatic unzipping utility that gets and install packages in R.
How do I find out what directory R has chosen to store packages?
How can I change the directory in which R stores and accesses packages?
This is documented in the 'R Installation and Administration' manual that came with your installation.
On my Linux box:
R> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"
[3] "/usr/lib/R/library"
R>
meaning that the default path is the first of these. You can override that via an argument to both install.packages()
(from inside R) or R CMD INSTALL
(outside R).
You can also override by setting the R_LIBS_USER variable.
The install.packages command looks through the .libPaths variable. Here's what mine defaults to on OSX:
> .libPaths()
[1] "/Library/Frameworks/R.framework/Resources/library"
I don't install packages there by default, I prefer to have them installed in my home directory. In my .Rprofile, I have this line:
.libPaths( "/Users/tex/lib/R" )
This adds the directory "/Users/tex/lib/R" to the front of the .libPaths variable.
Thanks for the direction from the above two answerers. James Thompson's suggestion worked best for Windows users.
C:\R\R-2.10.1\etc
.libPaths=("C:/R/library")
-the comment added to keep track of what I did to the file.
NOTE: there is likely more than one way to achieve this, but other methods I tried didn't work for some reason.