From d042f8f06b313e8595087587455daac73d84f17b Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 15 May 2017 20:01:28 +0200 Subject: Start of an Steps 1/2 calculator in R --- R/FOCUS_Step_12_scenarios.R | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 R/FOCUS_Step_12_scenarios.R (limited to 'R/FOCUS_Step_12_scenarios.R') diff --git a/R/FOCUS_Step_12_scenarios.R b/R/FOCUS_Step_12_scenarios.R new file mode 100644 index 0000000..cb0654a --- /dev/null +++ b/R/FOCUS_Step_12_scenarios.R @@ -0,0 +1,37 @@ +#' Step 1/2 scenario data as distributed with the FOCUS Step 1/2 calculator +#' +#' The data were extracted from the scenario.txt file using the R code shown below. +#' The text file is not included in the package as its licence is not clear. +#' +#' @name FOCUS_Step_12_scenarios +#' @docType data +#' @format A list containing the scenario names in a character vector called 'names', +#' the drift percentiles in a matrix called 'drift', interception percentages in +#' a matrix called 'interception' and the runoff/drainage percentages for Step 2 +#' calculations in a matrix called 'rd'. +#' @keywords datasets +#' @examples +#' +#' \dontrun{ +#' # This is the code that was used to extract the data +#' scenario_path <- "inst/extdata/FOCUS_Step_12_scenarios.txt" +#' scenarios <- readLines(scenario_path)[9:38] +#' FOCUS_Step_12_scenarios <- list() +#' sce <- read.table(text = scenarios, sep = "\t", header = TRUE, check.names = FALSE, +#' stringsAsFactors = FALSE) +#' FOCUS_Step_12_scenarios$names = sce$Crop +#' rownames(sce) <- sce$Crop +#' FOCUS_Step_12_scenarios$drift = sce[, 3:11] +#' FOCUS_Step_12_scenarios$interception = sce[, 12:15] +#' sce_2 <- readLines(scenario_path)[41:46] +#' rd <- read.table(text = sce_2, sep = "\t")[1:2] +#' rd_mat <- matrix(rd$V2, nrow = 3, byrow = FALSE) +#' dimnames(rd_mat) = list(Time = c("Oct-Feb", "Mar-May", "Jun-Sep"), +#' Region = c("North", "South")) +#' FOCUS_Step_12_scenarios$rd = rd_mat +#' save(FOCUS_Step_12_scenarios, file = "data/FOCUS_Step_12_scenarios.RData") +#' } +#' +#' # And this is the resulting data +#' FOCUS_Step_12_scenarios +NULL -- cgit v1.2.1