-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup_requirements.R
39 lines (35 loc) · 1.21 KB
/
setup_requirements.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
#!/usr/bin/Rscript --vanilla
# Module: Bachelor thesis
# Theme: Detect Malicious Login Events
# Author: Richard Mey <[email protected]>
# Status: 19.07.2021
cpus <- as.integer(sub("[^0-9]+", "", system("lscpu | grep ^CPU\\(s\\)\\:", intern = T)))
repository <- "https://cran.r-project.org/"
options(Ncpus = cpus - 1)
.libPaths("~/.R")
tryCatch(expr = {
cat("Installing required R packages, that could take some time to process.", fill = 1)
packages <- c("dplyr",
"ggplot2",
"tools",
"lubridate",
"doParallel",
"FactoMineR",
"factoextra",
"R.utils",
"reticulate",
"fmsb",
"BBmisc",
"ranger",
"caret",
"e1071",
"clue",
"yaml",
"kernlab"
)
suppressMessages(install.packages(setdiff(packages, rownames(installed.packages())), repos = repository, quiet = T))
write('.libPaths("~/.R")', file = file.path("~", ".Rprofile"), append = T)
}, error = function(e) {
stop("Error on installing all required R packages.", e, call. = F)
}
)