Skip to content

Instantly share code, notes, and snippets.

@dpastoor
Last active December 28, 2015 04:48
Show Gist options
  • Save dpastoor/7444664 to your computer and use it in GitHub Desktop.
Save dpastoor/7444664 to your computer and use it in GitHub Desktop.
Setup file for a fresh R install or new computer
libraries <- c(
"bear",
"deSolve",
"devtools",
"dplyr",
"formatR",
"ggplot2",
"gridExtra",
"installr",
"knitr",
"lattice",
"lme4",
"MASS",
"metafor",
"metrumrg",
"microbenchmark",
"mvtnorm",
"nlme",
"nlmeODE",
"npde",
"pacman",
"pander",
"plyr",
"psych",
"reports",
"reshape2",
"roxygen2",
"Rtools",
"sas7bdat",
"stargazer",
"survival",
"tidyr",
"xpose4",
"xtable"
)
install.packages(libraries)
### check.install function ###############################################
#still need to suppress warning message when trying to load package uninstalled
check.install <- function(libraries) {
#check to see which libraries and depenedencies are installed by loading them
inst <- lapply(libraries, require, character.only=T)
if (any(inst != TRUE)) {
notinst <- which(inst != TRUE)
cat(c("Libraries: ", "\n", libraries[notinst], "\n", "were not installed correctly"))
}
else print("Everything installed!")
}
check.install(libraries)
### Detach loaded packages #####################################################
unload.packages <- function() {
pkgs <- names(sessionInfo()$otherPkgs)
unload.pkgs <- paste('package:', pkgs, sep = "")
lapply(unload.pkgs, detach, character.only = TRUE, unload = TRUE, force = TRUE)
}
unload.packages()
### testing check.install function ###
# test <- list(TRUE, FALSE, TRUE, TRUE, TRUE, FALSE)
# test2 <- list(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE)
# testlib <- (letters[1:length(test)])
#
# notinst <- which(test != TRUE)
# any(test != TRUE)
# print(testlib[notinst])
# cat(c("Libraries: ", "\n", testlib[notinst], "\n", "were not installed correctly"))
### install slidify ############################################################
library(devtools)
install_github('slidify', 'ramnathv')
install_github('slidifyLibraries', 'ramnathv')
install_github("dpastoor/PKPDmisc")
install_github("dpastoor/PKPDdatasets")
### install pandoc #############################################################
library(installr)
installr()
#select pandoc from selection menu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment