rstudio averigüe si el paquete está instalado

#Easy way to check if packages are already installed in RStudio
packages <- c("ggplot2", "dplyr", "Hmisc", "lme4", "arm", "lattice", "lavaan")
if (length(setdiff(packages, rownames(installed.packages()))) > 0) {
  install.packages(setdiff(packages, rownames(installed.packages())))  
}
Hurt Hornet