(v0.7.1.9068) gramstain to freq()

This commit is contained in:
dr. M.S. (Matthijs) Berends committed 2019-08-30 14:50:56 +02:00
1 parent 34a82d091e
commit 88ee1b7268
15 files changed
+211 -238

No files matched your search

+15 -4
View File
@@ -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