diff --git a/DESCRIPTION b/DESCRIPTION
index 67d1666b..320a78ed 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: AMR
-Version: 1.3.0.9033
-Date: 2020-09-28
+Version: 1.3.0.9034
+Date: 2020-09-29
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(role = c("aut", "cre"),
diff --git a/NEWS.md b/NEWS.md
index 5b9ed41a..62306a9e 100755
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,5 @@
-# AMR 1.3.0.9033
-## Last updated: 28 September 2020
+# AMR 1.3.0.9034
+## Last updated: 29 September 2020
Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly!
diff --git a/R/atc_online.R b/R/atc_online.R
index d18487ab..52e59520 100644
--- a/R/atc_online.R
+++ b/R/atc_online.R
@@ -94,7 +94,7 @@ atc_online_property <- function(atc_code,
}
if (!has_internet()) {
- message("There appears to be no internet connection.")
+ message("There appears to be no internet connection, returning NA.")
return(rep(NA, length(atc_code)))
}
diff --git a/R/eucast_rules.R b/R/eucast_rules.R
index 42a71bf8..280ff1bc 100755
--- a/R/eucast_rules.R
+++ b/R/eucast_rules.R
@@ -475,7 +475,6 @@ eucast_rules <- function(x,
all_betalactams <- c(aminopenicillins, cephalosporins, carbapenems, ureidopenicillins, AMC, OXA, FLC, PEN)
# nolint end
-
# Some helper functions ---------------------------------------------------
get_antibiotic_columns <- function(x, df) {
x <- trimws(unlist(strsplit(x, ",", fixed = TRUE)))
@@ -547,6 +546,8 @@ eucast_rules <- function(x,
suppressWarnings(as.rsi(x))
}
+ # Preparing the data ------------------------------------------------------
+
verbose_info <- data.frame(rowid = character(0),
col = character(0),
mo_fullname = character(0),
@@ -884,18 +885,16 @@ eucast_rules <- function(x,
# Print overview ----------------------------------------------------------
if (info == TRUE) {
- rownames(verbose_info) <- NULL
- affected <- x.bak[which(x.bak$`.rowid` %in% x$`.rowid`), , drop = FALSE]
- rows_affected <- as.integer(rownames(affected))
- verbose_info <- verbose_info %pm>%
- pm_left_join(data.frame(row = rows_affected,
- rowid = affected[, ".rowid", drop = TRUE],
- stringsAsFactors = FALSE),
- by = "rowid") %pm>%
- pm_select(-rowid) %pm>%
+ verbose_info <- x.bak %pm>%
+ pm_mutate(row = pm_row_number()) %pm>%
+ pm_select(`.rowid`, row) %pm>%
+ pm_right_join(verbose_info,
+ by = c(".rowid" = "rowid")) %pm>%
+ pm_select(-`.rowid`) %pm>%
pm_select(row, pm_everything()) %pm>%
pm_filter(!is.na(new)) %pm>%
pm_arrange(row, rule_group, rule_name, col)
+ rownames(verbose_info) <- NULL
if (verbose == TRUE) {
wouldve <- "would have "
@@ -904,15 +903,17 @@ eucast_rules <- function(x,
}
cat(paste0("\n", font_grey(strrep("-", 0.95 * options()$width)), "\n"))
- cat(font_bold(paste("The rules", paste0(wouldve, "affected"),
- formatnr(pm_n_distinct(verbose_info$row)),
+ cat(paste0("The rules ", paste0(wouldve, "affected "),
+ font_bold(formatnr(pm_n_distinct(verbose_info$row)),
"out of", formatnr(nrow(x.bak)),
- "rows, making a total of", formatnr(nrow(verbose_info)), "edits\n")))
-
- total_n_added <- verbose_info %pm>% pm_filter(is.na(old)) %pm>% nrow()
- total_n_changed <- verbose_info %pm>% pm_filter(!is.na(old)) %pm>% nrow()
-
- # print added values
+ "rows"),
+ ", making a total of ",
+ font_bold(formatnr(nrow(verbose_info)), "edits\n")))
+
+total_n_added <- verbose_info %pm>% pm_filter(is.na(old)) %pm>% nrow()
+total_n_changed <- verbose_info %pm>% pm_filter(!is.na(old)) %pm>% nrow()
+
+# print added values
if (total_n_added == 0) {
colour <- cat # is function
} else {
diff --git a/R/rsi.R b/R/rsi.R
index 11b3bf0d..5f8cfb64 100755
--- a/R/rsi.R
+++ b/R/rsi.R
@@ -657,7 +657,7 @@ exec_as.rsi <- function(method,
pm_filter(uti == FALSE) %pm>% # 'uti' is a column in rsi_translation
pm_arrange(pm_desc(nchar(mo)))
}
- get_record <- get_record[1L, ]
+ get_record <- get_record[1L, , drop = FALSE]
if (NROW(get_record) > 0) {
if (is.na(x[i])) {
@@ -670,7 +670,7 @@ exec_as.rsi <- function(method,
isTRUE(conserve_capped_values) & mic_input %like% "^>[0-9]" ~ "R",
# start interpreting: EUCAST uses <= S and > R, CLSI uses <=S and >= R
isTRUE(which(levels(mic_input) == mic_input) <= which(levels(mic_S) == mic_S)) ~ "S",
- guideline_coerced %like% "ECUAST" &
+ guideline_coerced %like% "EUCAST" &
isTRUE(which(levels(mic_input) == mic_input) > which(levels(mic_R) == mic_R)) ~ "R",
guideline_coerced %like% "CLSI" &
isTRUE(which(levels(mic_input) == mic_input) >= which(levels(mic_R) == mic_R)) ~ "R",
@@ -681,7 +681,7 @@ exec_as.rsi <- function(method,
} else if (method == "disk") {
new_rsi[i] <- quick_case_when(isTRUE(as.double(x[i]) >= as.double(get_record$breakpoint_S)) ~ "S",
# start interpreting: EUCAST uses >= S and < R, CLSI uses >=S and <= R
- guideline_coerced %like% "ECUAST" &
+ guideline_coerced %like% "EUCAST" &
isTRUE(as.double(x[i]) < as.double(get_record$breakpoint_R)) ~ "R",
guideline_coerced %like% "CLSI" &
isTRUE(as.double(x[i]) <= as.double(get_record$breakpoint_R)) ~ "R",
diff --git a/docs/404.html b/docs/404.html
index 50ca67e0..8edbb951 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -81,7 +81,7 @@
NEWS.md
-
Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly!