mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 13:42:04 +02:00
(v0.7.1.9068) gramstain to freq()
This commit is contained in:
19
R/freq.R
19
R/freq.R
@ -29,11 +29,22 @@ clean::freq
|
||||
#' @export
|
||||
#' @noRd
|
||||
freq.mo <- function(x, ...) {
|
||||
x_noNA <- x[!is.na(x)]
|
||||
grams <- mo_gramstain(x_noNA, language = NULL)
|
||||
freq.default(x = x, ...,
|
||||
.add_header = list(families = n_distinct(mo_family(x, language = NULL)),
|
||||
genera = n_distinct(mo_genus(x, language = NULL)),
|
||||
species = n_distinct(paste(mo_genus(x, language = NULL),
|
||||
mo_species(x, language = NULL)))))
|
||||
.add_header = list(`Gram-negative` = paste0(format(sum(grams == "Gram-negative", na.rm = TRUE),
|
||||
big.mark = ",",
|
||||
decimal.mark = "."),
|
||||
" (", percent(sum(grams == "Gram-negative", na.rm = TRUE) / length(grams), force_zero = TRUE),
|
||||
" of total)"),
|
||||
`Gram-positive` = paste0(format(sum(grams == "Gram-positive", na.rm = TRUE),
|
||||
big.mark = ",",
|
||||
decimal.mark = "."),
|
||||
" (", percent(sum(grams == "Gram-positive", na.rm = TRUE) / length(grams), force_zero = TRUE),
|
||||
" of total)"),
|
||||
genera = n_distinct(mo_genus(x_noNA, language = NULL)),
|
||||
species = n_distinct(paste(mo_genus(x_noNA, language = NULL),
|
||||
mo_species(x_noNA, language = NULL)))))
|
||||
}
|
||||
|
||||
#' @exportMethod freq.rsi
|
||||
|
Reference in New Issue
Block a user