Skip to content

Instantly share code, notes, and snippets.

@dceoy
Last active August 29, 2015 14:02
Show Gist options
  • Save dceoy/c472e300cd0423023869 to your computer and use it in GitHub Desktop.
Save dceoy/c472e300cd0423023869 to your computer and use it in GitHub Desktop.
[R] Load packages
#!/usr/bin/env Rscript
load_pkgs <- function(pkgs, repos = 'http://cran.rstudio.com/') {
update.packages(checkBuilt = TRUE, ask = FALSE, repos = repos)
sapply(pkgs,
function(p) {
if (! p %in% installed.packages()[,1]) install.packages(p, dependencies = TRUE, repos = repos)
require(p, character.only = TRUE)
})
}
# example
load_pkgs(pkgs = c('dplyr',
'data.table',
'RSQLite',
'foreach',
'doSNOW',
'ggplot2'))
source('http://bioconductor.org/biocLite.R')
biocLite()
# export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib/
install.packages('Rmpi',
configure.args = c('--with-Rmpi-include=/usr/include/openmpi-x86_64/', # where mpi.h is located
'--with-Rmpi-libpath=/usr/lib64/openmpi/lib/', # where libmpi.so is located
'--with-Rmpi-type=OPENMPI'))
Sys.setenv(MAKEFLAGS = '-j4')
source('http://mc-stan.org/rstan/install.R', echo = TRUE, max.deparse.length = 2000)
install_rstan()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment