Install R packages in archive

2020-03-24 11:03发布

问题:

How can I install packages that are in archive, in Windows ?

http://cran.r-project.org/src/contrib/Archive/

When I try to install the tar.gz downloaded from the archive I get the following error:

Error in gzfile(file, "r") : cannot open the connection
In addition: Warning messages:
1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
2: In gzfile(file, "r") :
  cannot open compressed file 'grasp_2.5-7.tar.gz/DESCRIPTION', probable reason 'No such file or directory'

回答1:

You can try the function install_version in devtools. Let us suppose you want to install version 0.8 of ggplot2, you can call it as install_version('ggplot2', '0.8'). If you are on Windows, you can follow the instructions here to build packages from source.



回答2:

You can download the sources (tar.gz files) and install them using:

R CMD INSTALL packagename.tar.gz


回答3:

I had the same problem installing graph package from archive. The package is required for another package (bnclasify).

chooseBioCmirror() #select a different mirror than CRAN. This mirror may be #because is the one that has bnclasify in it (check this statement)

setRepositories() #In here you can select as many as you want to search for the       #package you need

ap <- available.packages() #list of all available packages

"graph" %in% rownames(ap) #search the package you need by name (return TRUE or #FALSE). 

install.packages("graph", dependencies=TRUE) #if the last statement TRUE then #install the package like normally