# Install required packages for RTutor from CRAN and Github # Run this code if you want to install RTutor problem sets on shinyapps.io # Otherwise you can more easily install RTutor via # install.packages("RTutor",repos = c("https://skranz-repo.github.io/drat/",getOption("repos"))) install.rtutor = function(update.cran=FALSE, update.github=TRUE, lib=.libPaths()[1], upgrade="never", force=TRUE,...) { cat("\nInstall required packages from CRAN...") # Avoid devtools::install_github warnings converted to errors # See https://remotes.r-lib.org/#environment-variables Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS="true") pkgs = c("withr","devtools","whisker","stringr","jsonlite","data.table","markdown","DT","dplyr","shiny","shinyBS","hwriter","lmtest","texreg","RCurl", "memoise","shinyAce","restorepoint") for (pkg in pkgs) { if (!update.cran) { if (!require(pkg, character.only=TRUE) | update.cran) try(install.packages(pkg,lib=lib)) } else { try(detach(paste0("package:",pkg), character.only=TRUE, force=TRUE), silent=TRUE) try(install.packages(pkg,lib=lib)) } } cat("\nInstall required packages from Github...") # Install packages from Github repos = c( "skranz/stringtools", "skranz/shinyEvents", "skranz/dplyrExtras", "skranz/regtools", "skranz/RTutor" ) library(withr) for (repo in repos) { pkg = strsplit(repo,"/", fixed=TRUE)[[1]][2] if (!update.github) { if (!require(pkg, character.only=TRUE) | overwrite.github) try(with_libpaths(new = lib, devtools::install_github(repo=repo, upgrade=upgrade,...))) } else { try(detach(paste0("package:",pkg), character.only=TRUE,force=TRUE), silent=TRUE) try(with_libpaths(new = lib, devtools::install_github(repo=repo, upgrade=upgrade, force=force,...))) } } library(RTutor) } # install.rtutor()