-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_package_cran_1.R
More file actions
25 lines (23 loc) · 923 Bytes
/
check_package_cran_1.R
File metadata and controls
25 lines (23 loc) · 923 Bytes
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
# Source script to check for packages available from Cran:
(this.check.cran.source.script <- "check_package_cran_1.R")
cat("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", "\n")
cat(paste("Loaded source:", this.check.cran.source.script), "\n")
cat("Function to call: check.package.cran(package list)", "\n")
cat("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", "\n")
check.package.cran <- function(package.list) {
(pkges <- installed.packages()[,"Package"])
for (pack.i in package.list) {
if (! pack.i %in% pkges) {
cat("************************************", "\n")
cat(paste("Installing CRAN package:", pack.i), "\n")
cat("************************************", "\n")
install.packages(pack.i)
} # end if
} # end for
# If necessary, load package:
for (pack.i in package.list) {
require(pack.i, character.only=TRUE)
} # end for
} # end function
## Update packages:
update.packages(ask=FALSE)