简体   繁体   中英

Install R package to a specific directory

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?

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
> 

Try running R studio as administrator. If you are using ubuntu start R using sudo R

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.

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