diff --git a/DESCRIPTION b/DESCRIPTION index d8f4795c..4f8050d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.8.2.9031 -Date: 2022-10-21 +Version: 1.8.2.9032 +Date: 2022-10-22 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by diff --git a/NEWS.md b/NEWS.md index c466a9fa..f8974eec 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.8.2.9031 +# AMR 1.8.2.9032 This version will eventually become v2.0! We're happy to reach a new major milestone soon! diff --git a/R/aa_globals.R b/R/aa_globals.R index 750622d8..a80fc64f 100755 --- a/R/aa_globals.R +++ b/R/aa_globals.R @@ -94,6 +94,8 @@ globalVariables(c( "atc_group1", "atc_group2", "base_ab", + "ci_min", + "ci_max", "code", "cols", "count", diff --git a/R/add_custom_antimicrobials.R b/R/add_custom_antimicrobials.R index b8437803..25058daf 100644 --- a/R/add_custom_antimicrobials.R +++ b/R/add_custom_antimicrobials.R @@ -111,26 +111,19 @@ add_custom_antimicrobials <- function(x) { } AMR_env$custom_ab_codes <- c(AMR_env$custom_ab_codes, x$ab) class(AMR_env$AB_lookup$ab) <- "character" - - bind_rows <- import_fn("bind_rows", "dplyr", error_on_fail = FALSE) - if (is.null(bind_rows)) { - # do the binding in base R - new_df <- AMR_env$AB_lookup[0, , drop = FALSE][seq_len(NROW(x)), , drop = FALSE] - rownames(new_df) <- NULL - list_cols <- vapply(FUN.VALUE = logical(1), new_df, is.list) - for (l in which(list_cols)) { - # prevent binding NULLs in lists, replace with NA - new_df[, l] <- as.list(NA_character_) - } - for (col in colnames(x)) { - # assign new values - new_df[, col] <- x[, col, drop = TRUE] - } - AMR_env$AB_lookup <- unique(rbind(AMR_env$AB_lookup, new_df)) - } else { - # otherwise use dplyr - AMR_env$AB_lookup <- unique(bind_rows(AMR_env$AB_lookup, x)) + + new_df <- AMR_env$AB_lookup[0, , drop = FALSE][seq_len(NROW(x)), , drop = FALSE] + rownames(new_df) <- NULL + list_cols <- vapply(FUN.VALUE = logical(1), new_df, is.list) + for (l in which(list_cols)) { + # prevent binding NULLs in lists, replace with NA + new_df[, l] <- as.list(NA_character_) } + for (col in colnames(x)) { + # assign new values + new_df[, col] <- x[, col, drop = TRUE] + } + AMR_env$AB_lookup <- unique(rbind(AMR_env$AB_lookup, new_df)) class(AMR_env$AB_lookup$ab) <- c("ab", "character") message_("Added ", nr2char(nrow(x)), " record", ifelse(nrow(x) > 1, "s", ""), " to the internal `antibiotics` data set.") } diff --git a/R/rsi_calc.R b/R/rsi_calc.R index 87003eff..cb9173e5 100755 --- a/R/rsi_calc.R +++ b/R/rsi_calc.R @@ -279,7 +279,6 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both" col_results <- as.data.frame(as.matrix(table(values)), stringsAsFactors = FALSE) col_results$interpretation <- rownames(col_results) col_results$isolates <- col_results[, 1, drop = TRUE] - ddf <<- col_results if (NROW(col_results) > 0 && sum(col_results$isolates, na.rm = TRUE) > 0) { if (sum(col_results$isolates, na.rm = TRUE) >= minimum) { col_results$value <- col_results$isolates / sum(col_results$isolates, na.rm = TRUE) diff --git a/inst/tinytest/test-zzz.R b/inst/tinytest/test-zzz.R index 6d98315e..73a74104 100644 --- a/inst/tinytest/test-zzz.R +++ b/inst/tinytest/test-zzz.R @@ -34,7 +34,6 @@ import_functions <- c( "%chin%" = "data.table", "anti_join" = "dplyr", - "bind_rows" = "dplyr", "chmatch" = "data.table", "cur_column" = "dplyr", "full_join" = "dplyr",