If you use the R
programming language, you probably know how much of a pain it is to keep your packages updated. You’ve run update.packages(...)
on the few that you want to keep up to date, but it’s a pain in the neck to do that for every package, every time. Thankfully, where there’s a will, there’s a way!
When R
starts up, it looks at your .Rprofile
file (if you have one), and runs it. Mine looks like this:
#!/usr/bin/Rscript
options("repos"="http://cran.stat.ucla.edu/")
library(utils)
update.packages(ask = FALSE)
my.packages = c("CvM2SL2Test", "MASS", "verification", "gtools", "ROCR",
"RColorBrewer", "heatmap.plus", "gmodels", "gplots",
"profr", "proftools",
"colorRamps")
to.download = which(!my.packages %in% rownames(installed.packages()))
if( length(to.download) > 0){
install.packages(my.packages[to.download], clean=TRUE, dependencies=TRUE)
}
This script has three awesome features:
It may be a little redundant, but having a few fail-safes never hurt anyone.
Feel free to steal this .Rprofile
for your own usage.