Reputation: 14370
I know how to specify where packages I install via install.packages
or R CMD
are going.
When I install within R
I always get the
The downloaded source packages are in
‘/tmp/RtmpxtIlp5/downloaded_packages’
Can I setup some environment or something so it always go where I want it to go ?
EDIT
Not sure if this is new but the good answer is to use destdir
install.packages(pkgs='versions', destdir='/tmp/sources', lib='/tmp/library', dependencies=TRUE, repos='http://cran.us.r-project.org')
Upvotes: 3
Views: 1186
Reputation: 368231
I use the script install.r
included as an example in the littler package (which is also available as a binary for several Linux distrubtions including Debian and Ubuntu). As a side-effect, it leaves packages in /tmp/download_packages
:
edd@max:~$ install.r digest
trying URL 'http://cran.rstudio.com/src/contrib/digest_0.6.8.tar.gz'
Content type 'application/x-gzip' length 97985 bytes (95 KB)
==================================================
downloaded 95 KB
* installing *source* package ‘digest’ ...
** package ‘digest’ successfully unpacked and MD5 sums checked
** libs
gcc -I/usr/share/R/include -DNDEBUG [...]
gcc -I/usr/share/R/include -DNDEBUG [...]
[...]
gcc -shared -L/usr/lib/R/lib [...]
installing to /usr/local/lib/R/site-library/digest/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (digest)
The downloaded source packages are in
‘/tmp/downloaded_packages’
edd@max:~$
As they are not delete (as done by the default R session) you could easily script it to copy them to some other directory.
Upvotes: 2
Reputation: 2409
You can use the dir
argument of install
. Like so:
install.packages("yourPackage", dir="your/install/dir")
There is no global option in Rstudio for that argument. I poked around in the R directory, and couldn't find anything. As a global workaround:
installDir = "your/install/dir"
...
install.packages("yourPackage", dir=installDir)
Not ideal, but it will work.
Upvotes: 0