Phantom Photon
Phantom Photon

Reputation: 808

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?

Upvotes: 33

Views: 79605

Answers (8)

JeeyCi
JeeyCi

Reputation: 597

e.g. from github

# Install
if(!require(devtools)) install.packages("devtools")
devtools::install_github("kassambara/ggpubr")
#Or, install from CRAN as follow:
install.packages("ggpubr")

from zipped win-binary r-release (loaded from here with manual here)

install.packages("C:\\evir_1.7-4.zip", repos = NULL, type="source")
library(evir)
# TEST IT - from manual:
# Find threshold giving (at least) fifty exceedances for Danish data
data(danish)
findthresh(danish, 50)

Upvotes: 1

Reader 123
Reader 123

Reputation: 367

If it is a package that has been removed from the repo but you have an installed version (and want to e.g. move it), you can do this in RStudio on Windows:

  1. zip the folder in which the package currently is (using any of the usual programs, 7zip, etc.)
  2. move it to a folder accessible from the R version you want to install to
  3. in RStudio click on Tools->Install packages and choose "Package Archive File (zip; tar.gz)" in the "Install from" dropdown.

I have just managed to move an obsolete package using this method and it can be loaded as expected.

Upvotes: 2

Jeff Bezos
Jeff Bezos

Reputation: 2283

I was able to do this using devtools:

devtools::install("path/to/package/folder")

Upvotes: 9

Shanmuga Priya
Shanmuga Priya

Reputation: 11

  1. Go to R-studio

  2. Click the install icon in the packages section found in the right side of the window

  3. A new window pops up

  4. Set "Install from: Package Archive file" "Package Archive: Browse the unzipped file and select it"

  5. Click install
    This installs the package to the R library

Upvotes: 1

Logit
Logit

Reputation: 591

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")

Upvotes: 53

Orhan Celik
Orhan Celik

Reputation: 1575

If you have zip file, you can install as follows

install.packages("E:\\R-Packages\\plyr_1.8.4.zip", repos = NULL, type="source")

Upvotes: 3

Thomas
Thomas

Reputation: 44565

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.

Upvotes: 6

thc
thc

Reputation: 9705

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")

Upvotes: 7

Related Questions