download and install the latest R and packages

Created on Aug 15 2013
Revised on Thu Aug 15 16:16:05 2013

related post is here and here

1. Re-Install of R

If you are running R on Windows, you can use the following code to quickly download and install the latest R version using the installr package

if(!require(installr)) { 
install.packages("installr")
require(installr)} #load / install+load installr
updateR() # this will only work AFTER R 3.0.0 will be released to your CRAN mirror

2. Re-Install of Packages

2.1 Automated Re-Install of Packages (packages in the default library dir)

update.packages(ask=FALSE, checkBuilt = TRUE)

2.2 if you have installed packages in other dir [not the default library dir]

.libPaths()  # gets the library trees within which packages are looked for
myPath=c("C:/Users/alice/Documents/R/win-library/3.0") # change it to your own dir
package_df <- as.data.frame(installed.packages(myPath)) # #Get currently installed packages
package_list <- as.character(package_df$Package)
install.packages(package_list) #Re-install Install packages