|
5 | 5 | #' @param org organization (short name in WQP) whose data should be used to build the report. Multiple organization names can be input as a character vector; names will be homogenized and data will be pooled for analysis purposes. A list of acceptable organization names is available in this csv: https://cdx.epa.gov/wqx/download/DomainValues/Organization.CSV.
|
6 | 6 | #' @param startDate start date for data used in the report, in format `\%m-\%d-\%Y`
|
7 | 7 | #' @param endDate final date for data used in the report, in format `\%m-\%d-\%Y`
|
8 |
| -#' @param parameters parameters to use in report. Must be entered as an index of acceptable parameters listed in params$params (e.g., `parameters = c(1:4,7)`) |
| 8 | +#' @param parameters parameters to use in report. Can be entered as exact characteristic names (for a complete list, see: https://cdx.epa.gov/wqx/download/DomainValues/Characteristic.CSV). Alternatively, this argument can be a numeric index of parameters listed in params$params (e.g., `parameters = c(1:4,7)`) |
9 | 9 | #' @param extFile name of report-generating script, located in the inst/extdata folder of the R8WD R package
|
10 | 10 | #' @param prompt_user if TRUE, user is prompted to use one of the organization short names in the `tribes` object provided with `R8WD`. .
|
11 | 11 | #' @param output either 'docx' or 'html'
|
|
21 | 21 | create_report <- function(org = 'TURTLEMT',
|
22 | 22 | startDate = '01-01-2015',
|
23 | 23 | endDate = '12-31-2022',
|
24 |
| - parameters = 1:11, |
| 24 | + parameters = c('Total Phosphorus, mixed forms', 'Total Nitrogen, mixed forms', 'Escherichia coli', 'Dissolved oxygen (DO)', 'Temperature', 'Temperature, water', 'pH', 'Turbidity', 'Conductivity', 'Total suspended solids'), |
25 | 25 | extFile = 'script_generateReport.qmd',
|
26 | 26 | prompt_user = TRUE,
|
27 | 27 | output = 'html',
|
@@ -70,7 +70,13 @@ create_report <- function(org = 'TURTLEMT',
|
70 | 70 | ### add params
|
71 | 71 | # parameters
|
72 | 72 | # REPLACE_PARAMS
|
73 |
| - newParams <- paste0(paste0(gsub(x = as.character(parameters), pattern = "\'|\"", replacement = ''), collapse = ',')) |
| 73 | + if (all(is.numeric(parameters))) { |
| 74 | + newParams <- paste0(paste0(gsub(x = as.character(parameters), pattern = "\'|\"", replacement = ''), collapse = ',')) |
| 75 | + } else if (all(is.character(parameters))) { |
| 76 | + # newParams <- dput(parameters) |
| 77 | + newParams <- paste0('"', x = paste0(gsub(x = as.character(parameters), pattern = "\'|\"", replacement = "'"), collapse='","'), '"') |
| 78 | + } |
| 79 | + |
74 | 80 | # tst <- gsub(x = readLines(targetFile), pattern = token, replacement = newParams)
|
75 | 81 | newText <- gsub(x = newText, pattern = '\'REPLACE_PARAMS\'', replacement = newParams)
|
76 | 82 |
|
|
0 commit comments