Update all user installed R packages – again

November 10, 2014
By

(This article was first published on Rainer's Blog » R, and kindly contributed to R-bloggers)

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
install.packages(package_list)

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:

install.packages( 
    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,

Rainer

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.

To leave a comment for the author, please follow the link and comment on their blog: Rainer's Blog » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)