Re-installing the same packages in R 3.0.0

Do this part in R 2.15.3

## Create a vector of all packages installed currently
vector.of.installed.packages <- rownames(installed.packages())

## Save this vector in a dataset
save(vector.of.installed.packages, file = "vector.of.installed.packages.RData")

Do this part in R 3.0.0

## Load the vector created in R 2.15.3
load("vector.of.installed.packages.RData")

## Create a vector of packages installed by default in R 3.0.0
vector.of.default.packages <- rownames(installed.packages())

## Create a vector of packages not already installed
vector.of.packages.to.install <- setdiff(vector.of.installed.packages,
                                         vector.of.default.packages)

## Install these packages
install.packages(pkgs = vector.of.packages.to.install)

Appendix: setdiff() etc

## Create x and y vectors
(x <- c(sort(sample(1:20, 9)), NA))
 [1]  2  3  4  8 10 11 15 17 18 NA
(y <- c(sort(sample(3:23, 7)), NA))
[1]  7 12 14 20 21 22 23 NA

## elements of x not included in y
setdiff(x, y)
[1]  2  3  4  8 10 11 15 17 18
## elements of y not included in x
setdiff(y, x)
[1]  7 12 14 20 21 22 23
## elements of either
union(x, y)
 [1]  2  3  4  8 10 11 15 17 18 NA  7 12 14 20 21 22 23
## elements of both
intersect(x, y)
[1] NA
## Do they have the same elements?
setequal(x, y)
[1] FALSE