Skip to content

Instantly share code, notes, and snippets.

@skranz
Last active February 24, 2021 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save skranz/fad6062e5462c9d0efe4 to your computer and use it in GitHub Desktop.
Save skranz/fad6062e5462c9d0efe4 to your computer and use it in GitHub Desktop.
# 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()
@skranz
Copy link
Author

skranz commented Sep 18, 2019

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment