1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 23:21:56 +02:00

(v0.8.0.9030) depend on tidyr >= 1.0.0

This commit is contained in:
2019-11-11 10:46:39 +01:00
parent d22834c5b8
commit 248b45da71
28 changed files with 580 additions and 515 deletions

View File

@ -32,7 +32,7 @@
#' @inheritParams rsi_df
#' @inheritParams base::formatC
#' @importFrom dplyr %>% rename group_by select mutate filter summarise ungroup
#' @importFrom tidyr spread
#' @importFrom tidyr pivot_longer
#' @details The function \code{format} calculates the resistance per bug-drug combination. Use \code{combine_IR = FALSE} (default) to test R vs. S+I and \code{combine_IR = TRUE} to test R+I vs. S.
#'
#' The language of the output can be overwritten with \code{options(AMR_locale)}, please see \link{translate}.
@ -80,7 +80,7 @@ bug_drug_combinations <- function(x,
FUN(...)) %>%
group_by(mo) %>%
select_if(is.rsi) %>%
gather("ab", "value", -mo) %>%
pivot_longer(-mo, names_to = "ab") %>%
group_by(mo, ab) %>%
summarise(S = sum(value == "S", na.rm = TRUE),
I = sum(value == "I", na.rm = TRUE),
@ -93,7 +93,7 @@ bug_drug_combinations <- function(x,
}
#' @importFrom dplyr everything rename %>% ungroup group_by summarise mutate_all arrange everything lag
#' @importFrom tidyr spread
#' @importFrom tidyr pivot_wider
#' @importFrom cleaner percentage
#' @exportMethod format.bug_drug_combinations
#' @export
@ -135,7 +135,7 @@ format.bug_drug_combinations <- function(x,
}
ab_txt
}
y <- x %>%
mutate(ab = as.ab(ab),
ab_txt = give_ab_name(ab = ab, format = translate_ab, language = language)) %>%
@ -146,8 +146,9 @@ format.bug_drug_combinations <- function(x,
mutate(txt = paste0(percentage(isolates / total, decimal.mark = decimal.mark, big.mark = big.mark),
" (", trimws(format(isolates, big.mark = big.mark)), "/",
trimws(format(total, big.mark = big.mark)), ")")) %>%
select(ab, ab_txt, mo, txt) %>%
spread(mo, txt) %>%
select(ab, ab_txt, mo, txt) %>%
arrange(mo) %>%
pivot_wider(names_from = mo, values_from = txt) %>%
mutate_all(~ifelse(is.na(.), "", .)) %>%
mutate(ab_group = ab_group(ab, language = language),
ab_txt) %>%