Loading all installed R packages

December 10, 2012

[This article was first published on The Praise of Insects, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The other day I was trying to set up an R for Windows installation on a USB drive. As I don’t have a Windows machine, I had to use the university computer to do this task. However, for some reason, they’ve blocked R from downloading and installing packages using the install.packages() command. This required that I download the zip files and manually install them. No problem with that, until packages require the installation of dependencies. To ensure that I got all the packages I needed, I wanted a function that would load all of the packages locally installed on my machine. To my surprise, I didn’t find a straight-forward solution, so I came up with the following kludge:

lapply(.packages(all.available = TRUE), function(xx) library(xx,     character.only = TRUE))

There may be a more elegant way to do the above, but it worked. Elegance is occasionally overrated.

To leave a comment for the author, please follow the link and comment on their blog: The Praise of Insects.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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


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)