6

I am posting this issue here as I suppose it bothered many R users. It is recommended to update R and packages as frequently as possible (see https://community.rstudio.com/t/should-i-update-all-my-r-packages-frequently-yes-no-why/5856). Yet, this can be time consuming to look if your version is the latest one, download the last version of R and reinstall all your packages.

Recently I discovered the installr package. It provided the very nice function updateR(). According to the documentation, the updateR() function performs the following: finding the latest R version, downloading it, running the installer, deleting the installation file, copy and updating old packages to the new R installation

Thanks to this post: How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?

Rtist
  • 3,825
  • 2
  • 31
  • 40
  • "Although it is recommended to update R several times per year." is it? – mhovd Dec 18 '19 at 10:35
  • I changed it a little bit and added a reference – Rtist Dec 18 '19 at 10:52
  • 1
    I don't know in which field you work, but I would advise you the opposite: do not update packages that often. The main reason to do so is because of `reproducibility`. You want the results of a pipeline to be the same/comparable today, tomorrow, and in 8 months. – fra Dec 18 '19 at 11:30
  • @fra That what tests are there for. Also, you can install R without removing old versions. Just "install R for the first time." I have every version since 3.2.3 on my system. – Roland Dec 18 '19 at 11:39

2 Answers2

5

Windows To update R on Windows, try using the package installr (only for Windows)

Install and load installr: install.packages("installr") and library(installr) Call updateR() function. This will start the updating process of your R installation by: “finding the latest R version, downloading it, running the installer, deleting the installation file, copy and updating old packages to the new R installation.” From within RStudio, go to Help > Check for Updates to install newer version of RStudio (if available, optional). You are ready for Data Science Essentials for R!

Mac On Mac, you can simply download and install the newest version of R. When you restart RStudio, it will use the updated version of R.

Go to https://cloud.r-project.org/bin/macosx/ Click the link “R-3.5.2.pkg” When the file finishes downloading, double-click to install. You should be able to click “Next” to all dialogs to finish the installation. From within RStudio, go to Help > Check for Updates to install newer version of RStudio (if available, optional). To update packages, go to Tools > Check for Package Updates. If updates are available, select All (or just tidyverse), and click Install Updates. You are ready for Data Science Essentials for R!

For more details see below link https://uvastatlab.github.io/phdplus/installR.html

KApril
  • 632
  • 1
  • 8
  • 20
3

If you're using Mac or Linux you can use a package manager for that.

On Mac you can use brew. On Linux it depends on your distribution. Most ditros ship with a default package manager. On Manjaro it's pamac. This approach has the advantage that it lets you automatically update all programs which you obtained using the package manager and not just R.

BerriJ
  • 913
  • 7
  • 18
  • 2
    On WIndows the package manager [chocolatey](https://chocolatey.org/packages/R.Project) does the same. You can also update RStudio with it. The package manager concept seems weird for many Windows users but they usually get around after a while. Especially when they are used to R already. – JBGruber Dec 18 '19 at 13:57