Created
April 23, 2019 15:43
-
-
Save larsvilhuber/85026976027b58714c00420d75f04281 to your computer and use it in GitHub Desktop.
Install R packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################### | |
# global libraries used everywhere # | |
#################################### | |
# Package lock in - optional | |
MRAN.snapshot <- "2019-01-01" | |
options(repos = c(CRAN = paste0("https://mran.revolutionanalytics.com/snapshot/",MRAN.snapshot))) | |
pkgTest <- function(x) | |
{ | |
if (!require(x,character.only = TRUE)) | |
{ | |
install.packages(x,dep=TRUE) | |
if(!require(x,character.only = TRUE)) stop("Package not found") | |
} | |
return("OK") | |
} | |
global.libraries <- c("dplyr","devtools","rprojroot","tictoc") | |
results <- sapply(as.list(global.libraries), pkgTest) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ########################### | |
# CONFIG: define paths and filenames for later reference | |
# ########################### | |
# Change the basepath depending on your system | |
basepath <- rprojroot::find_rstudio_root_file() | |
# Main directories | |
dataloc <- file.path(basepath, "data","replication_data") | |
interwrk <- file.path(basepath, "data","interwrk") | |
Outputs <- file.path(basepath, "analysis" ) | |
programs <- file.path(basepath,"programs") | |
for ( dir in list(dataloc,interwrk,Outputs)){ | |
if (file.exists(dir)){ | |
} else { | |
dir.create(file.path(dir)) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment