-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlibraries.R
53 lines (44 loc) · 1.26 KB
/
libraries.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
####################################
# global libraries used everywhere #
####################################
mran.date <- "2021-10-01"
get_os <- function(){
sysinf <- Sys.info()
if (!is.null(sysinf)){
os <- sysinf['sysname']
if (os == 'Darwin')
os <- "osx"
} else { ## mystery machine
os <- .Platform$OS.type
if (grepl("^darwin", R.version$os))
os <- "osx"
if (grepl("linux-gnu", R.version$os))
os <- "linux"
}
tolower(os)
}
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")
}
if (get_os()=="linux") {
## Rstudio Package Manager
options(repos = c(REPO_NAME = paste0("https://packagemanager.rstudio.com/all/__linux__/bionic/",mran.date,"+Y3JhbiwyOjQ1MjYyMTU7NDJGRDU3MTc")))
} else {
## MRAN
options(repos=paste0("https://cran.microsoft.com/snapshot/",mran.date,"/"))
}
global.libraries <- c("dplyr","devtools","rprojroot","tictoc","ggplot2","tidycensus","readr","webshot")
# now install the rest
results <- sapply(as.list(global.libraries), pkgTest)
# webshot extra config
if (webshot::is_phantomjs_installed()) {
message("PhantomJS already installed")
} else {
webshot::install_phantomjs()
}