mirror of
https://github.com/msberends/AMR.git
synced 2026-03-19 22:22:30 +01:00
Replace glue-style dynamic markup with paste0() construction
{.field {variable}} and {.cls {variable}} patterns rely on glue
evaluation which is not safe in a zero-dependency package. Replace
all four occurrences with paste0("{.field ", var, "}") so the value
is baked into the markup string before reaching message_()/stop_().
https://claude.ai/code/session_01XHWLohiSTdZvCutwD7ag2b
This commit is contained in:
8
R/sir.R
8
R/sir.R
@@ -835,7 +835,7 @@ as.sir.data.frame <- function(x,
|
||||
message_(
|
||||
"Assuming value", plural[1], " ",
|
||||
vector_and(col_values, quotes = TRUE),
|
||||
" in column {.field {col_specimen}} reflect", plural[2], " ", plural[3], "urinary tract infection", plural[1],
|
||||
" in column ", paste0("{.field ", col_specimen, "}"), " reflect", plural[2], " ", plural[3], "urinary tract infection", plural[1],
|
||||
".\n Use `as.sir(uti = FALSE)` to prevent this."
|
||||
)
|
||||
}
|
||||
@@ -974,7 +974,7 @@ as.sir.data.frame <- function(x,
|
||||
if (!all(x[, ab, drop = TRUE] %in% c("S", "SDD", "I", "R", "NI", NA), na.rm = TRUE)) {
|
||||
show_message <- TRUE
|
||||
if (isTRUE(info)) {
|
||||
message_("Cleaning values in column {.field {ab}} (",
|
||||
message_("Cleaning values in column ", paste0("{.field ", ab, "}"), " (",
|
||||
ifelse(ab_coerced != toupper(ab), paste0(ab_coerced, ", "), ""),
|
||||
ab_name(ab_coerced, tolower = TRUE, info = info), ")... ",
|
||||
appendLF = FALSE,
|
||||
@@ -984,7 +984,7 @@ as.sir.data.frame <- function(x,
|
||||
} else if (!is.sir(x.bak[, ab, drop = TRUE])) {
|
||||
show_message <- TRUE
|
||||
if (isTRUE(info)) {
|
||||
message_("Assigning class {.cls sir} to already clean column {.field {ab}} (",
|
||||
message_("Assigning class {.cls sir} to already clean column ", paste0("{.field ", ab, "}"), " (",
|
||||
ifelse(ab_coerced != toupper(ab), paste0(ab_coerced, ", "), ""),
|
||||
ab_name(ab_coerced, tolower = TRUE, language = NULL, info = info), ")... ",
|
||||
appendLF = FALSE,
|
||||
@@ -2232,7 +2232,7 @@ check_reference_data <- function(reference_data, .call_depth) {
|
||||
bad_col <- names(class_ref[class_sir != class_ref][1])
|
||||
bad_cls <- gsub("<|>", "", class_ref[class_sir != class_ref][1])
|
||||
exp_cls <- gsub("<|>", "", class_sir[class_sir != class_ref][1])
|
||||
stop_("{.arg reference_data} must be the same structure as the {.topic [clinical_breakpoints](AMR::clinical_breakpoints)} data set. Column {.field {bad_col}} is of class {.cls {bad_cls}}, but should be of class {.cls {exp_cls}}", call = .call_depth)
|
||||
stop_("{.arg reference_data} must be the same structure as the {.topic [clinical_breakpoints](AMR::clinical_breakpoints)} data set. Column ", paste0("{.field ", bad_col, "}"), " is of class ", paste0("{.cls ", bad_cls, "}"), ", but should be of class ", paste0("{.cls ", exp_cls, "}"), call = .call_depth)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user