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"
)

# Fonction pour vérifier et charger les packages
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)
  }
}
install.packages("shinyBS",repos='http://cran.rstudio.com/')
library("shinyBS")
# Charger les packages requis
load_or_install(required_packages)

options(shiny.port=8080)
options(lauch.browser=FALSE)
source("ui.R")
source("server.R")

shinyApp(ui = ui, server = server)