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.
The South Pacific, insect taxonomy, and anything else that takes my interest....
Tuesday, 11 December 2012
Loading all installed R packages
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:
This comment has been removed by the author.
ReplyDeleteHave a look at "installed.packages()"
ReplyDeleteWhat problem are you trying to solve? Typically, assuming you've installed the dependencies, the 'library' command will automatically grab dependencies.
ReplyDeleteSam sounds like an I.T department security thing? You can ask them to let you do this on the uni computer if it's causing you problems... But seems like you got around it! K
ReplyDeletePerfect if you previously assign the list to a variable (L) and then:
ReplyDeleteunique(unlist(L))
Sir, You have saved me from an extensive n painful search through my packages for defunct packages.Thank you.
ReplyDelete