Based on the answer to this question: An elegant way to check for missing packages and install them?
I use the following code to make sure all packages are installed when I upgrade R or configure 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 put it in my .First function in my .Rprofile, but when I run R, it gives the following error and continues to run:
Error in match(x, table, nomatch = 0L) : could not find function "installed.packages"
If I run the code after receiving the prompt, it works fine. Any ideas why?
Thanks!
source share