R

Specifically regarding R code

Versions

Install Older Package from Source

# P: package name, e.g. "ggplot2"
# V: version number, e.g. "3.3.5"

#single install 
install.packages(
  "https://cran.r-project.org/src/contrib/Archive/<P>/<P>_<V>.tar.gz"
  , repos=NULL
  , type="source"
)

#function to install (for multiple instances)
library(glue) 
install_old_version <- function(P, V){
  if (packageVersion(P) == V){
    logger::log_info("Package already at that version")
  } else {
    packageurl <- as.character(glue(
    "https://cran.r-project.org/src/contrib/Archive/{P}/{P}_{V}.tar.gz"
    ))
    install.packages(packageurl, repos=NULL, type="source")
    logger::log_success("{P} {V}")
  }
}

Install Older Version of R (Windows)

If a program was built entirely in an older version of R, it may be difficult to get it to work with an updated version of R. When their isn’t time to investigate and re-code, installing an older version of R is possible.

  1. cran.r-project.org
  2. Click the ‘Download for Windows’ link for your given operating system
  3. Click on the ‘base’ link
  4. Click on the ‘Previous releases’ link
  5. Click on the specific R version you want, say R 3.5.3
  6. Click on the ‘Download R for Windows’ and this will download an exe file
  7. Run the exe file to install the older version of R

Switch between versions of R

  1. Open R Studio
  2. Tools > Global Options…
  3. General > R Version > Change…