Update all user installed R packages – again

And I had to do it again: I am using R installed from homebrew, and after the upgrade from Mavericks to Yosemite, I had to re-install all packages – or was it a GCC upgrade? I don’t know – but I had to do it again.

I still had the link to Randys Zwitch’s solution but I think there were some shortcomings. His solution is as follows:

## Get currently installed packages
package_df <- as.data.frame(installed.packages("/Library/Frameworks/R.framework/Versions/2.15/Resources/library"))
package_list <- as.character(package_df$Package)

## Re-install Install packages

The shortfalls were:

  • hard coded path to the library
  • I don’t like factors…
  • I want (need) to install from source

So I just revised the script slightly and came up with this solution:

    lib  = lib <- .libPaths()[1],
    pkgs = as.data.frame(installed.packages(lib), stringsAsFactors=FALSE)$Package,
    type = 'source'

Very similar, but, most importantly, the path is not hardcoded.

Hope this helps somebody.

Cheers and enjoy life,


P.S: The enjoy life has become more important for me – a friend died in an helicopter crash and he left his wife with two little children. Life is really to short and can end anytime – to precious not be enjoyed. RIP.


9 responses to “Update all user installed R packages – again

  1. i’m truly sorry for your loss. my best friend died at the age of 24, on September 13, 2014. it really is a hard thing to experience, but it sounds like you are appreciating and celebrating his memories. it’s all we can do.

    • Nope – this only updates when the version of R was upgraded after the last comple. Inmy case, the rebuild was necessary because of an OS or compiler upgrade. TheE conditions are not covered by check built.

  2. I would like to suggest RStudio. You can update all of your packages very easily and in one step through the GUI. (Don’t get me wrong, I love the cmd line but RStudio is really pretty great!)

    • Rstudio is a great GUI for R, but i prefer emacs & ESS. And only install Rsrudik to update? And i don’t think Rstudio would update in my case of an OS or compiler update.

  3. Many thanks for this. I responsibly set up my OS to update via the package manager. It downloaded a new version of “R-patched” from one respository … and somehow a version of “R-base” right as I’m working on a laborious problem set.

    All packages must be replaced. All hail google and your script.

  4. Pingback: Atualizando a versão do R (2016) e todos os pacotes instalados (Ubuntu/Linux) – Métrico

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s