1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-10 17:01:52 +02:00
This commit is contained in:
2023-01-21 11:47:02 +01:00
parent ee38689172
commit 79c8415d3e
13 changed files with 22 additions and 22 deletions

View File

@ -37,7 +37,7 @@
#' @param FUN the function to call on the `mo` column to transform the microorganism codes, defaults to [mo_shortname()]
#' @param translate_ab a [character] of length 1 containing column names of the [antibiotics] data set
#' @param ... arguments passed on to `FUN`
#' @inheritParams sir_sf
#' @inheritParams sir_df
#' @inheritParams base::formatC
#' @details The function [format()] calculates the resistance per bug-drug combination. Use `combine_SI = TRUE` (default) to test R vs. S+I and `combine_SI = FALSE` to test R+I vs. S.
#' @export

View File

@ -41,7 +41,7 @@
#'
#' The function [n_sir()] is an alias of [count_all()]. They can be used to count all available isolates, i.e. where all input antibiotics have an available result (S, I or R). Their use is equal to `n_distinct()`. Their function is equal to `count_susceptible(...) + count_resistant(...)`.
#'
#' The function [count_df()] takes any variable from `data` that has an [`sir`] class (created with [as.sir()]) and counts the number of S's, I's and R's. It also supports grouped variables. The function [sir_sf()] works exactly like [count_df()], but adds the percentage of S, I and R.
#' The function [count_df()] takes any variable from `data` that has an [`sir`] class (created with [as.sir()]) and counts the number of S's, I's and R's. It also supports grouped variables. The function [sir_df()] works exactly like [count_df()], but adds the percentage of S, I and R.
#' @inheritSection proportion Combination Therapy
#' @seealso [`proportion_*`][proportion] to calculate microbial resistance and susceptibility.
#' @return An [integer]

View File

@ -53,7 +53,7 @@
#' @details At default, the names of antibiotics will be shown on the plots using [ab_name()]. This can be set with the `translate_ab` argument. See [count_df()].
#'
#' ### The Functions
#' [geom_sir()] will take any variable from the data that has an [`sir`] class (created with [as.sir()]) using [sir_sf()] and will plot bars with the percentage S, I, and R. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis.
#' [geom_sir()] will take any variable from the data that has an [`sir`] class (created with [as.sir()]) using [sir_df()] and will plot bars with the percentage S, I, and R. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis.
#'
#' [facet_sir()] creates 2d plots (at default based on S/I/R) using [ggplot2::facet_wrap()].
#'
@ -340,7 +340,7 @@ geom_sir <- function(position = NULL,
ggplot2::geom_col(
data = function(x) {
sir_sf(
sir_df(
data = x,
translate_ab = translate_ab,
language = language,
@ -521,7 +521,7 @@ labels_sir_count <- function(position = NULL,
colour = datalabels.colour,
lineheight = 0.75,
data = function(x) {
transformed <- sir_sf(
transformed <- sir_df(
data = x,
translate_ab = translate_ab,
combine_SI = combine_SI,

View File

@ -53,7 +53,7 @@
#'
#' These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the [`count()`][AMR::count()] functions to count isolates. The function [susceptibility()] is essentially equal to `count_susceptible() / count_all()`. *Low counts can influence the outcome - the `proportion` functions may camouflage this, since they only return the proportion (albeit being dependent on the `minimum` argument).*
#'
#' The function [proportion_df()] takes any variable from `data` that has an [`sir`] class (created with [as.sir()]) and calculates the proportions S, I, and R. It also supports grouped variables. The function [sir_sf()] works exactly like [proportion_df()], but adds the number of isolates.
#' The function [proportion_df()] takes any variable from `data` that has an [`sir`] class (created with [as.sir()]) and calculates the proportions S, I, and R. It also supports grouped variables. The function [sir_df()] works exactly like [proportion_df()], but adds the number of isolates.
#' @section Combination Therapy:
#' When using more than one variable for `...` (= combination therapy), use `only_all_tested` to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Drug A and Drug B, about how [susceptibility()] works to calculate the %SI:
#'
@ -206,11 +206,11 @@
#' proportion_df(translate = FALSE)
#'
#' # It also supports grouping variables
#' # (use sir_sf to also include the count)
#' # (use sir_df to also include the count)
#' example_isolates %>%
#' select(ward, AMX, CIP) %>%
#' group_by(ward) %>%
#' sir_sf(translate = FALSE)
#' sir_df(translate = FALSE)
#' }
#' }
resistance <- function(...,

View File

@ -372,5 +372,5 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
rownames(out) <- NULL
out <- as_original_data_class(out, class(data.bak)) # will remove tibble groups
structure(out, class = c("sir_sf", class(out)))
structure(out, class = c("sir_df", "rsi_df", class(out)))
}

View File

@ -29,7 +29,7 @@
#' @rdname proportion
#' @export
sir_sf <- function(data,
sir_df <- function(data,
translate_ab = "name",
language = get_AMR_locale(),
minimum = 30,

Binary file not shown.

View File

@ -98,14 +98,14 @@ if (utf8_supported && !is_latex) {
s3_register("pillar::pillar_shaft", "av")
s3_register("pillar::pillar_shaft", "mo")
s3_register("pillar::pillar_shaft", "sir")
s3_register("pillar::pillar_shaft", "rsi") # TODO deprecate in a later version
s3_register("pillar::pillar_shaft", "rsi") # remove in a later version
s3_register("pillar::pillar_shaft", "mic")
s3_register("pillar::pillar_shaft", "disk")
s3_register("pillar::type_sum", "ab")
s3_register("pillar::type_sum", "av")
s3_register("pillar::type_sum", "mo")
s3_register("pillar::type_sum", "sir")
s3_register("pillar::type_sum", "rsi")
s3_register("pillar::type_sum", "rsi") # remove in a later version
s3_register("pillar::type_sum", "mic")
s3_register("pillar::type_sum", "disk")
# Support for frequency tables from the cleaner package