mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 06:06:12 +01:00
cleanup
This commit is contained in:
parent
d0b54f640c
commit
d10651eb26
@ -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
|
||||
|
2
NEWS.md
2
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!
|
||||
|
||||
|
@ -94,6 +94,8 @@ globalVariables(c(
|
||||
"atc_group1",
|
||||
"atc_group2",
|
||||
"base_ab",
|
||||
"ci_min",
|
||||
"ci_max",
|
||||
"code",
|
||||
"cols",
|
||||
"count",
|
||||
|
@ -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.")
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user