process_arguments: Process arguments of calling script

View source: R/Extractions_Main.R

process_argumentsR Documentation

Process arguments of calling script

Description

Process arguments of calling script

Usage

process_arguments(x)

Arguments

x

A vector of character strings. The return value of commandArgs.

Value

A named list with the processed arguments.

Details

The available command-line options are

  • -o=output_filename: output file name (without extension)

  • -fun=fun_metric: name of a metric function

  • -fparam=param_filename: file name of the R script with parameters; see system.file("exec", "Project_Parameters.R", package = "rSW2metrics") for a template

  • ⁠-mode=[{TRUE,test}|{FALSE,full,any,}]⁠: option for running a test; if TRUE or test, then the metric function is extracting only from the first ntests runs; all available runs are extracted (default) if option is missing or contains any other value

  • -ntests=x: number of runs used if in test mode (-mode) with a default of x=100

  • -runids=r1:r2: sequence of runs defined by first r1 and last r2 run (from available runs) from which metrics are extracted;

    • if missing and in full mode (-mode), then all available runs are used (default);

    • if missing and in test mode, then option -ntests is used;

    • if in test mode and both -ntests and -runids are present, then -runids takes precedence

  • -ncores=x: size of parallel (socket) cluster used to extract fun_metric from runs (default x=1)

  • ⁠-cllog=[{TRUE,}|{FALSE,any}]⁠: logging activity on cluster to disk (default FALSE)

  • ⁠-add_aggs_across_yrs=[{TRUE,}|{FALSE,any}]⁠: across-year summaries (defined by fun_aggs_across_yrs() from fparam) added to output if option is present and fun_metric produces time-series output

Examples

process_arguments(
  c(
   "-o=AI_annual",
   "-fun=metric_AI",
   "-fparam=Project_Parameters.R",
   "-add_aggs_across_yrs",
   "-ncores=2"
  )
)


DrylandEcology/rSW2metrics documentation built on May 25, 2023, 10:38 a.m.