-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall_packages.R
35 lines (27 loc) · 986 Bytes
/
install_packages.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
cat("Installing packages...\n")
Sys.sleep(1)
install.packages("common")
req_file <- common::file.find(pattern = "req.txt")
# Read text file containing required packages
if(!file.exists(req_file)) {
warning(req_file, "was not found. No packages installed or checked.")
return()
}
req <- scan(req_file, character(), quiet = TRUE)
# Install missing packages
if (length(req) > 0) {
missing_packages <- req[!(req %in% installed.packages()[,"Package"])]
if (length(missing_packages) > 0) {
cat("Number of packages to install: ", length(missing_packages), "\n")
pak::pkg_install(missing_packages, ask = FALSE)
}
}
# Load packages
suppressPackageStartupMessages(invisible(lapply(req, library, character.only = TRUE)))
# options
options(dplyr.summarise.inform = FALSE)
# special case for packages not on CRAN
if (!require("MALDIcellassay", character.only = TRUE)) {
pak::pkg_install("CeMOS-Mannheim/MALDIcellassay")
library(MALDIcellassay, character.only = TRUE)
}