16

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?

Chris Barlow
  • 3,274
  • 4
  • 31
  • 52
user3703268
  • 163
  • 1
  • 1
  • 5

3 Answers3

14

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
> 
Bill
  • 10,323
  • 10
  • 62
  • 85
2

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.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
-1

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

Vikram Venkat
  • 663
  • 4
  • 16
  • 3
    Since running RStudio as administrator is not necessary, they only would do so because they did not understand what exactly is happening and how to address it safely. But that lack of understanding is precisely why they should **not** be running anything as administrator in the first place. – hyginn Apr 12 '19 at 18:25