Here’s a very naive program I just wrote to update all of the R packages I have on my system after I update the core R binary. Please let me know if there’s anything obviously wrong with this, such as failing to update items with chains of dependencies.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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)
}
} |
Why not just use update.packages() ?
Because I didn’t know it existed? Thanks for pointing it out, Bryan. From now I’ll just run this command regularly:
update.packages(ask = FALSE, dependencies = c('Suggests'))