How to install package from download zip file
I downloaded this package as a zip file.
Is it possible to install it from the R console using this zip or unzip version at a specific path?
install.packages("C:/Users/Desktop/rvest-master.zip', lib='C:/R/R-3.2.1',repos = NULL)
I type the previous command but it doesn't work
> setwd("C:/Users/Desktop/")
> unzip("rvest-master.zip")
> file.rename("rvest-master", "rvest")
[1] TRUE
> shell("R CMD build rvest")
Warning messages:
1: running command ' /c R CMD build rvest' had status 127
2: In shell("R CMD build rvest") :
'R CMD build rvest' execution failed with error code 127
> install.packages("rvest_0.2.0.9000.tar.gz", repos = NULL)
Installing package into ‘C:/Users/Documents/R/win-library/3.2
(as ‘lib is unspecified)
Warning: invalid package 'rvest_0.2.0.9000.tar.gz'
Error: ERROR: no packages specified
Warning messages:
1: running command '"C:/R/R-3.2.1/bin/x64/R" CMD INSTALL -l "C:\Users\Documents\R\win-library\3.2" "rvest_0.2.0.9000.tar.gz"' had status 1
2: In install.packages("rvest_0.2.0.9000.tar.gz", repos = NULL) :
installation of package ‘rvest_0.2.0.9000.tar.gz had non-zero exit status
The previous line shows the results of the answer
source to share
You have downloaded the zip code of the package source. This is not a standard package source package, nor is it a standard Windows binary (i.e. a built-in package redistributed as a .zip like from CRAN).
The simplest thing you need to do is install this package directly from Github using devtools:
library("devtools")
install_github("hadley/rvest")
If you choose to install it locally, you need to unzip the package directory, build it from the command line with R CMD build rvest
, and then install either with R CMD INSTALL
or from R using the command you already have (but run on the tarball you built). Here's how you could do it all from within R:
setwd("C:/Users/Desktop/")
unzip("rvest-master.zip")
file.rename("rvest-master", "rvest")
shell("R CMD build rvest")
This will make the tarball version of the package in the current directory. Then you can install this with
install.packages("rvest_0.2.0.9000.tar.gz", repos = NULL)
Since the version number is concatenated with the tarball name, it may not always be obvious that a new file can be called. You can use list.files()
to grab a new archive.
install.packages(list.files(pattern="rvest*.tar.gz"), repos = NULL)
If the line shell()
gives you an error like
'R' is not recognized as an internal or external command
You need to make sure R is in your shell path. You can add it with something like
Sys.setenv(PATH=paste(R.home("bin"), Sys.getenv("PATH"), sep=";"))
source to share
On Windows 7 and R 3.5.3 I had to extract the zip, repack it as .tar.gz and then install it using the command below. When zip is installed, the package will not be indexed by R.
install.packages("C:/your-package.tar.gz", repos = NULL, type = "win.binary", lib="C:/Users/username/Documents/R/R-3.5.3/library")
Environment
version _
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 5.3
2019 year
month 03
day 11
svn rev 76217
language R
version.string R version 3.5.3 (2019-03-11) nickname Great Truth
source to share
If it is the zip code of the package source and the R core install.packages()
does not work, then you can use install_local()
from the package devtools
.
I do this a lot when installing packages from GitHub, since rolling through our proxy is painful. So I downloaded the original zip and installed like this.
source to share