-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2021-06-11-R_install_pkgs
31 lines (22 loc) · 1.05 KB
/
2021-06-11-R_install_pkgs
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
## Modify based on code from https://stackoverflow.com/questions/46902203/verify-r-packages-installed-into-docker-container
c("ggplot2", "NMF", "ggalluvial", "ggrepel",'cowplot','ComplexHeatmap','RSpectra','RcppEigen','gg.gap','BiocGenerics','patchwork') -> chk_pkgs
ret <- suppressPackageStartupMessages(
sapply(chk_pkgs, require, character.only = TRUE, quietly = FALSE, warn.conflicts = FALSE)
)
missing_pkgs <- names(ret[!ret])
if (length(missing_pkgs) > 0) {
warning("The following packages are not installed: ",
paste0(sprintf(" - %s", missing_pkgs), collapse = "\n"),
immediate. = TRUE
)
message("Try installing them...")
BiocManager::install(missing_pkgs)
ret <- suppressPackageStartupMessages(
sapply(chk_pkgs, require, character.only = TRUE, quietly = FALSE, warn.conflicts = FALSE)
)
missing_pkgs <- names(ret[!ret])
if (length(missing_pkgs) > 0) {
warning("Still cannot fix installing problem, quit with -1.", immediate. = TRUE)
}
}
quit(save = "no", status = ifelse(length(missing_pkgs) == 0, 0, -1), runLast = FALSE)