# Set CRAN mirror
chooseCRANmirror(ind=1)

# Function to install a package if it's not already installed
install_if_missing <- function(package) {
  if (!require(package, character.only = TRUE)) {
    install.packages(package)
  }
}

# Install CRAN packages
cran_packages <- c("Matrix", "Rcpp", "RcppArmadillo", "devtools",  "MASS", "MLmetrics", "emstreeR", "caret", "glasso", "BigQuic")
sapply(cran_packages, install_if_missing)

# Install GitHub packages using devtools
sapply(c("ramhiser/datamicroarray", "cescwang85/EQUAL"), function(repo) {
  if (!require(sub("/", "_", repo), character.only = TRUE)) {
    devtools::install_github(repo)
  }
})

# Install a package from a local source (alread installed from "make install")
#install.packages("../Src/r", repos = NULL, type = "source")
