Reputation: 4298
I find it annoying that I have to click Tools -> Update Packages every time I load RStudio. I could use update.packages(c("ggplot2"))
for instance to update my packages in .RProfile, but the issue is that it won't look for other packages (dependencies). For instance, I have to update "seriation" and "digest" package every time I start RStudio, and these packages are not loaded by me at start-up. Does anyone have code to automatically check and update all packages at start-up ? If so, can you please share here? I extensively googled this topic and searched through SO, and it seems that popular opinion is to use RStudio's menu. Here's the thread I am referring to: How to update R2jags in R?
One way I can think of doing this is in .RProfile:
a<-installed.packages()
b<-data.frame(a[,1])
and then calling this function: https://gist.github.com/stevenworthington/3178163
However, I am not quite sure whether this is the most optimal method.
Another linked thread is: Load package at start-up
I created the thread above. I'd appreciate any thoughts.
Upvotes: 2
Views: 370
Reputation: 1022
i found this on internet(don't remember where) when i was struggling with the same problem, though you still need to run this program . Hope this helps .
all.packages <- installed.packages()
r.version <- paste(version[['major']], '.', version[['minor']], sep = '')
for (i in 1:nrow(all.packages))
{
package.name <- all.packages[i, 1]
package.version <- all.packages[i, 3]
if (package.version != r.version)
{
print(paste('Installing', package.name))
install.packages(package.name)
}
}
Upvotes: 1