Installing Older Version of R Package

Installing older version of R package

To install an older version of a package from source (within R):

packageurl <- "http://cran.r-project.org/src/contrib/Archive/ggplot2/ggplot2_0.9.1.tar.gz"
install.packages(packageurl, repos=NULL, type="source")

If this doesn't work for you and you're on Windows, the reason is probably the lack of an appropriate tool chain for building/compiling packages. Normally you would install a pre-compiled binary from CRAN but they only archive package sources, not binaries.[1] This means you need to install Rtools so that you can compile everything locally. (Note: Rtools is not an R package.)

@shadow's answer below also makes the case that you can use devtools::install_version(). That's also a good idea, but is also subject to needing Rtools on Windows.

As of September 18, 2015, a new package versions has appeared on CRAN. This relies on the Revolution Analytics MRAN server to install packages for specific versions or dates:

# install yesterday's version of checkpoint, by date
install.dates('checkpoint', Sys.Date() - 1)

# install earlier versions of checkpoint and devtools
install.versions(c('checkpoint', 'devtools'), c('0.3.3', '1.6.1'))

That has the advantage of not requiring Rtools to install binary packages on Windows, but only works going back to 2014-09-17 (when MRAN was launched).

To install an older version from the command line (outside of R):

You can also install a package by using R CMD INSTALL on the command line (Terminal, Command Prompt, etc.) once you have the package source ("tarball") locally on your machine, for example using wget (if you have it):

wget http://cran.r-project.org/src/contrib/Archive/ggplot2/ggplot2_0.9.1.tar.gz

or, if you're on Windows, an equivalent using PowerShell would be:

(new-object System.Net.WebClient).DownloadFile("http://cran.r-project.org/src/contrib/Archive/ggplot2/ggplot2_0.9.1.tar.gz", "./ggplot2_0.9.1.tar.gz")

or you can just download the source from the CRAN archive via your web browser.

To install from the local file, you can just do:

R CMD INSTALL ggplot2_0.9.1.tar.gz

That should work on any platform (with the same caveat - as above - about needing a tool chain for building packages).


[1]This is no longer entirely true. From March 2016, CRAN has started hosting a "CRAN Archive" server that contains Windows and Mac binaries for very old versions of R (> 5 years old). You can now install directly from this server using install.packages(). See new R FAQ 7.44 for some details.

Installing earlier version of R package not on CRAN

The remotes::install_git() function has a ref= parameter when you type a commit or tag name. If you tag your releases, then you can install which ever version you want with the correct tag. Your users don't need to run git themselves, but they will need access to the git repo to pull the correct version.

If you want to host your own repository for your users, you can also look into something like miniCRAN or drat. Since those basically a CRAN-like repository for your packages, you can probably use existing tools like the versions package to interact with the repo (assuming you keep older versions around in the same way CRAN does).

R how to install a specified version of a bioconductor package?

Bioconductor stores the package archives here: https://bioconductor.org/packages/3.6/bioc/src/contrib/Archive/

1) Locate and download the version you would like to install.

2) Install it using R CMD INSTALL yourpackage_version_x.y.z.tar.gz as
suggested by Eugène Adell in the comments.

If you cannot find the specific version on the bioconductor archive, then try to find it on the github repository of the package.

Problems installing older version of Bioconductor's mixOmics packages in R

BiocManager::install() doesn't provide an interface for installing specific versions of a package. The documentation for the version argument states:

version: 'character(1)' Bioconductor version to install, e.g.,
'version = "3.8"'. The special symbol 'version = "devel"'
installs the current 'development' version.

That is, it relates to the Bioconductor version, not the package version.

That said, you should be able to use renv to install a specific version of the package from Bioconductor. For example:

options(renv.settings.bioconductor.version = "3.11")
renv::install("bioc::mixOmics@6.12.1")

You could also use renv::settings$bioconductor.version("3.11") to store the required version of Bioconductor as a project setting, to be used by renv during restore().

I used the package RVAideMemoire which is tied in with mixOmics in bioconductor, which can't be loaded automatically using renv::restore().

I'd be curious to know why renv::restore() is failing for you.

EDIT: Based on your output, you're trying to use Bioconductor 3.12, but mixOmics 6.12.1 isn't available from that version of Bioconductor. You need to set the Bioconductor version used by renv as detailed in this answer. (You might also need to install the latest version of renv to gain support for this.)



Related Topics



Leave a reply



Submit