RRC|BIOSTATISTICS

Two Ways to Update R Packages

Hello friend! Did you just update your R to the latest version and now none of your packages work? Have no fear, lets work on it together:

Update R Packages via the Command Line

To update via the Linuxmachine, use this resource of Ubuntu Cran

For example, to download the latest version of ggplot2 since my updated R gave me a nasty message of package 'ggplot2' is not available (for R version 3.2.2 I used this link: http://packages.ubuntu.com/trusty/gnu-r/r-cran-ggplot2

You have two choices: 1) Get a highly outdated version of the package: sudo apt-get install r-cran-ggplot2

2) Or download the package via the Ubuntu Cran website. Make sure to look for .orig.tar.gz for the file name.

Then install with R CMD in your terminal, making sure you remember where you downloaded the folder. R CMD INSTALL --build r-cran-ggplot2_0.9.3.1.orig.tar.gz

SO. MANY. DEPENDENCIES.

R CMD install works for a hot minute until you need to download a package with a ton of dependencies. Like Caret, which is maintained by Max Kuhn.

Here is the easy solution when you’re done being silly with R CMD INSTALL:

install.packages('package_name', dependencies=TRUE, repos='http://cran.rstudio.com/')

So much easier.

Comments?

Did your R packages lose their functionality and disappear like a thief in the night when you updated R as well? Is there a way around this?

Comments