-
Notifications
You must be signed in to change notification settings - Fork 2
/
iris_rlog.R
44 lines (36 loc) · 1.05 KB
/
iris_rlog.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
#!/usr/bin/env Rscript
#' Usage:
#'
#' Rscript iris_rlog.R --species virginica > iris.log 2>&1
#' Rscript iris_rlog.R > iris.log 2>&1
#' Rscript iris_rlog.R --species maxima > iris.log 2>&1
#'
#' Rscript iris_rlog.R --species virginica > iris.log 2> iris.err
#' Rscript iris_rlog.R > iris.log 2> iris.err
#' Rscript iris_rlog.R --species maxima > iris.log 2> iris.err
#'
#' Note: this script requires the rlog package
info <- function(...) {
rlog::log_info(paste(...))
}
error <- function(...) {
rlog::log_error(paste(...))
if (!interactive())
q(status = 1)
}
abort <- function(...) {
error(geterrmessage())
}
options(digits.secs = 3, error = abort)
CONFIG <- rconfig::rconfig()
info("Started")
species <- rconfig::value(
CONFIG$species,
error("Species not provided")) # anticipated error
## Make invalid species names a non-anticipated error
# if (!(species %in% iris$Species))
# error("Provide a valid species")
info("Getting summaries for species", species)
summary(iris[iris$Species %in% species, 1:4])
info("Done")
q(status = 0)