Pablo Marin-Garcia
Pablo Marin-Garcia

Reputation: 4251

Is it possible to define the version of a package in R install.packages?

I know that you can download old packages and install them with

R CMD INSTALL package-version.tar.gz

I wonder if you can tell install.packages() to install a specific version from a repository, saving you from having to locate the tar.gz first. I have neither found this option in the help entry for install.packages nor googling for it. If this option does not exist, is there any reason for that?. I can only think that not all repos have all versions so you are forced to find the version first and download it.

There is an equivalent question already in SO but the problem and answer is more about repository problems, so at the end they never answered this question directly.

Upvotes: 11

Views: 6759

Answers (2)

Isaiah
Isaiah

Reputation: 63

remotes::install_version(package, version= version number, lib =location) and versions::install.dates(pkgs, dates, lib) are two other options. Also, checkpoint will fix the R version too.

library(checkpoint)
checkpoint("2020-01-01", r_version="3.6.2")

Upvotes: 1

Brian Diggs
Brian Diggs

Reputation: 58825

install.packages() does not, but there is a function install_version() in the devtools package which can install a version other than the most recent one from a CRAN repository.

Upvotes: 15

Related Questions