Based on the answer to this question: Elegant way to check for missing packages and install them?
I'm using the following code to make sure that all packages are installed when I upgrade R, or set up other users:
list.of.packages <- c("RODBC", "reshape2", "plyr")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
I've placed it in my .First function in my .Rprofile, but when I start up R it gives the following error and continues starting up:
Error in match(x, table, nomatch = 0L) :
could not find function "installed.packages"
If I run the code after I get a prompt it works fine. Any ideas why?
Thanks!