required_packages <- c(
  "shiny", "shinythemes", "DT", "ggplot2", "gridExtra", 
  "emmeans", "readxl", "dplyr", "carData", "car", 
  "factoextra", "shinylogs", "plotly", "auth0", 
  "httr", "shinyjs", "openssl", "urltools", 
  "pls", "shinyBS", "multcomp","lme4","nlme","MuMIn", "writexl"
)

load_or_install <- function(packages) {
  for (pkg in packages) {
    if (!require(pkg, character.only = TRUE)) {
      install.packages(pkg, dependencies = TRUE,repos='http://cran.rstudio.com/')
    }
    library(pkg,character.only=TRUE)
    print(pkg)
  }
}

load_or_install(required_packages)