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.