Skip to content

Instantly share code, notes, and snippets.

@dpastoor
Last active August 29, 2015 13:56
Show Gist options
  • Save dpastoor/9006585 to your computer and use it in GitHub Desktop.
Save dpastoor/9006585 to your computer and use it in GitHub Desktop.
package install list for new R install
packages <- c(
"bear",
"data.table",
"deSolve",
"devtools",
"dplyr",
"formatR",
"ggplot2",
"gridExtra",
"installr",
"knitr",
"lattice",
"lme4",
"MASS",
"metafor",
"metrumrg",
"microbenchmark",
"mvtnorm",
"nlme",
"nlmeODE",
"npde",
"pander",
"plyr",
"psych",
"reports",
"reshape2",
"roxygen2",
"Rtools",
"sas7bdat",
"shiny",
"stargazer",
"survival",
"xpose4",
"xtable"
)
for (p in setdiff(packages, installed.packages()[,"Package"])){
install.packages(p)
}
#github installs
library(devtools)
install_github("dpastoor/PKPDmisc")
install_github("dpastoor/PKPDdatasets")
install_github('slidify', 'ramnathv')
install_github('slidifyLibraries', 'ramnathv')
### 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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment