mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 02:03:04 +02:00
freq: fix na.rm in groups
This commit is contained in:
@ -97,7 +97,7 @@
|
||||
#' @rdname EUCAST
|
||||
#' @export
|
||||
#' @importFrom dplyr %>% select pull mutate_at vars
|
||||
#' @importFrom crayon bold bgGreen bgYellow bgRed black green blue italic
|
||||
#' @importFrom crayon bold bgGreen bgYellow bgRed black green blue italic strip_style
|
||||
#' @return The input of \code{tbl}, possibly with edited values of antibiotics. Or, if \code{verbose = TRUE}, a \code{data.frame} with verbose info.
|
||||
#' @source
|
||||
#' \itemize{
|
||||
@ -376,8 +376,8 @@ EUCAST_rules <- function(tbl,
|
||||
if (verbose == TRUE) {
|
||||
for (i in 1:length(cols)) {
|
||||
# add new row for every affected column
|
||||
verbose_new <- data.frame(rule_type = rule[1],
|
||||
rule_set = rule[2],
|
||||
verbose_new <- data.frame(rule_type = strip_style(rule[1]),
|
||||
rule_set = strip_style(rule[2]),
|
||||
force_to = to,
|
||||
found = length(before),
|
||||
changed = sum(before != after, na.rm = TRUE),
|
||||
|
5
R/freq.R
5
R/freq.R
@ -59,7 +59,7 @@
|
||||
#' The function \code{top_freq} uses \code{\link[dplyr]{top_n}} internally and will include more than \code{n} rows if there are ties.
|
||||
#' @importFrom stats fivenum sd mad
|
||||
#' @importFrom grDevices boxplot.stats
|
||||
#' @importFrom dplyr %>% arrange arrange_at desc funs group_by mutate mutate_at n_distinct pull select summarise tibble ungroup vars
|
||||
#' @importFrom dplyr %>% arrange arrange_at desc filter_at funs group_by mutate mutate_at n_distinct pull select summarise tibble ungroup vars all_vars
|
||||
#' @importFrom utils browseVignettes
|
||||
#' @importFrom hms is.hms
|
||||
#' @importFrom crayon red green silver
|
||||
@ -206,6 +206,9 @@ frequency_tbl <- function(x,
|
||||
df <- x %>%
|
||||
group_by_at(vars(x.group_cols)) %>%
|
||||
summarise(count = n())
|
||||
if (na.rm == TRUE) {
|
||||
df <- df %>% filter_at(vars(cols), all_vars(!is.na(.)))
|
||||
}
|
||||
if (!missing(sort.count)) {
|
||||
if (sort.count == TRUE) {
|
||||
df <- df %>% arrange_at(c(x.group, "count"), desc)
|
||||
|
Reference in New Issue
Block a user