Last active
February 24, 2021 01:07
-
-
Save skranz/fad6062e5462c9d0efe4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry, somehow I did not get a notification that there was a comment. Today, I just looked for another reason at the gist and saw it. You are of course completely, right: one time "memoise" is of course enough. I have updated the gist. Thanks a lot!