-
Notifications
You must be signed in to change notification settings - Fork 3
/
instFLR.R
48 lines (31 loc) · 1.23 KB
/
instFLR.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
# instFLR.R - Installation script for FLR packages
# Copyright 2014 FLR Team. Distributed under the GPL 2.
# Author: Iago Mosqueira, JRC
# Maintainer: Iago Mosqueira, JRC
# NOTES:
# GET pkg DESCRIPTIONs
flr <- available.packages(contriburl = contrib.url("http://flr-project.org/R"))
# OFFER FLR pkgs
pkgs <- select.list(rownames(flr), multiple=TRUE, title="FLR Packages",
preselect=NULL)
# ---- FLash CHECK platform OS and arch
arch <- .Platform
if("FLasher" %in% pkgs & arch$OS.type == "windows" & arch$r_arch != "x64")
stop("WARNING: FLasher pkg requires 64 bit R in Windows!")
# SUBSET desc
desc <- flr[flr[, 'Package'] %in% pkgs,,drop=FALSE]
# CHECK dependencies
deps <- gsub("[ \n]", "", gsub("\\(.*\\)", "", unlist(strsplit(paste(desc[, c("Depends", "Imports")]), ","))))
insp <- c("R", "NA", rownames(utils::installed.packages()))
# FIND missing
miss <- unique(unlist(lapply(deps, function(x) x[!x %in% insp])))
if(length(miss) > 0) {
# MSG
cat("INSTALLING pkg dependencies from CRAN \n")
# DROP FLR pkgs
miss <- miss[!miss %in% pkgs]
install.packages(miss)
}
# INSTALL from FLR repo
cat("INSTALLING FLR packages \n")
install.packages(pkgs, repos="http://flr-project.org/R")