Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install R package to a specific directory

Tags:

r

I tried this code to install R package to a directory where I stored my R packages.

install.packages("zoo", lib="/data/Rpackages/")

I got this warning message:

Warning in install.packages("zoo", lib = "/data/Rpackages/") : 'lib = "/data/Rpackages/"' is not writable

Secondly how do I create a file .Renviron in our home area and add the line R_LIBS=/data/Rpackages/ to it?

like image 246
user3703268 Avatar asked Jun 03 '14 13:06

user3703268


2 Answers

How do you actually get out of the warning situation? Is there a better way other than (in R Studio menus) Session->Interrupt R and terminating the R session? I tried CTRL-C.

> install.packages("car", lib="/my R packages/")
Warning in install.packages :
  'lib = "/my R packages/"' is not writable

My solution to the problem was to load the package within R Studio using the 'Packages' window which then does the following:

> install.packages("car")
Installing package into ‘C:/Users/33386/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/car_2.0-21.zip'
Content type 'application/zip' length 1332800 bytes (1.3 Mb)
opened URL
downloaded 1.3 Mb

package ‘car’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\33386\AppData\Local\Temp\RtmpKWnZD4\downloaded_packages
> 
like image 138
Bill Avatar answered Oct 26 '22 09:10

Bill


Briefly:

  1. Use chmod to change the directory mode: chmod u+w /data/R/packages. You may need sudo (or your admin) to do that.

  2. Use an editor and create and save a file: editor ~/.Renviron. You could also copy Renviron.site from R's etc/ directory and start from that.

like image 38
Dirk Eddelbuettel Avatar answered Oct 26 '22 07:10

Dirk Eddelbuettel