0
|
1 #!/usr/bin/env Rscript
|
|
2
|
13
|
3 options_list <- list(
|
22
|
4 make_option(c("-i", "--input_temperatures"), action="store", help="Input temperatures csv file"),
|
19
|
5 make_option(c("-s", "--save_log"), action="store_true", default=FALSE, help="Save R logs"),
|
22
|
6 make_option(c("-m", "--output_r_log"), action="store", help="Output dataset for R logs"),
|
|
7 make_option(c("-o", "--output"), action="store", help="Output dataset")
|
0
|
8 )
|
|
9
|
13
|
10 parser <- OptionParser(usage="%prog [options] file", options_list)
|
|
11 args <- parse_args(parser, positional_arguments=TRUE)
|
|
12 opt <- args$options
|
|
13
|
|
14
|
22
|
15 if (opt$save_log) {
|
|
16 rlogf <- file(opt$output_r_log, open="wt")
|
|
17 } else {
|
|
18 # Direct R messaging to a temporary file.
|
|
19 rlogf <- file("tmpRLog", open="wt")
|
19
|
20 }
|
22
|
21 sink(file=rlogf, type=c("output", "message"), append=FALSE, split=FALSE)
|
19
|
22
|
22
|
23 tempdata <- read.csv(opt$input_temperatures)
|
|
24 save(tempdata, file=opt$output)
|