Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing an R package from local unzipped folder

I am having difficulty installing an unzipped package on a Windows 7 computer without administrative privileges and no internet access. I am using the RGui (not RStudio).

Right now I have an unzipped library sitting in a directory. Unfortunately, when I try:

install.packages("C://path//to//directory", 
    repos = NULL, 
    lib = "C://path//to//newDirectory")

I am getting the error:

Warning in `install.packages("C://path//to//directory",`   :
   'lib = "C://path//to//newDirectory"' is not writable

Which is strange because I do have write privileges to where I am attempting to store the package.

When I get this error, I also get a popup from RGui:

Would you like to use a personal library instead?

If I click Yes, it throws the error:

Error in `install.packages("C://path//to//directory",`   :
    type == "both" cannot be used with 'repos = NULL'

I also cannot install devtools. Any ideas?

like image 388
Edward Tyler Avatar asked Mar 31 '17 22:03

Edward Tyler


People also ask

How do I install R packages from a zip file?

Go into R, click on Packages (at the top of the R console), then click on "Install package(s) from local zip files", then find the zip file with arm from wherever you just saved it. Do the same thing to install each of the other packages you want to install.


3 Answers

The solution to installing a package that's been unzipped into a folder is as follows:

install.packages("C:/path to folder with the package",  repos = NULL,  type = "source") 
like image 142
Logit Avatar answered Sep 17 '22 12:09

Logit


If it is an unzipped Windows binary (e.g., from CRAN), you can just copy and paste the entire package directory into your library folder. You could also, presumably, use file.copy() to do so if you wanted to do it within R. install.packages() is failing (weirdly) because you're giving it something other than the typical package source or zipped binary that it is expecting.

like image 44
Thomas Avatar answered Sep 18 '22 12:09

Thomas


I think the error message is actually just wrong. You need to give the file name of the package, not just the directory.

install.packages("C://path//to//directory//MY_PACKAGE.tar.gz", 
    repos = NULL, 
    lib = "C://path//to//newDirectory")
like image 20
thc Avatar answered Sep 18 '22 12:09

thc