Skip to content

Instantly share code, notes, and snippets.

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
# Otherwise you can more easily install RTutor via
# install.packages("RTutor",repos = c("",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
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)
} else {
try(detach(paste0("package:",pkg), character.only=TRUE, force=TRUE), silent=TRUE)
cat("\nInstall required packages from Github...")
# Install packages from Github
repos = c(
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,...)))
# install.rtutor()
Copy link

novica commented Apr 29, 2019

On line 10 "memoise" is listed twice. Is that needed?

Copy link

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