packages <- c("ggplot2", "Rcpp") new.packages <- packages[!(packages %in% installed.packages()[, "Package"])] if (length(new.packages) > 0) { install.packages(new.packages) }