mirror of
				https://github.com/msberends/AMR.git
				synced 2025-10-31 11:28:18 +01:00 
			
		
		
		
	fixes
This commit is contained in:
		| @@ -387,9 +387,9 @@ export(set_AMR_locale) | ||||
| export(set_ab_names) | ||||
| export(set_mo_source) | ||||
| export(sir_confidence_interval) | ||||
| export(sir_df) | ||||
| export(sir_interpretation_history) | ||||
| export(sir_predict) | ||||
| export(sir_sf) | ||||
| export(skewness) | ||||
| export(streptogramins) | ||||
| export(susceptibility) | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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] | ||||
|   | ||||
| @@ -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, | ||||
|   | ||||
| @@ -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(..., | ||||
|   | ||||
| @@ -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))) | ||||
| } | ||||
|   | ||||
| @@ -29,7 +29,7 @@ | ||||
|  | ||||
| #' @rdname proportion | ||||
| #' @export | ||||
| sir_sf <- function(data, | ||||
| sir_df <- function(data, | ||||
|                    translate_ab = "name", | ||||
|                    language = get_AMR_locale(), | ||||
|                    minimum = 30, | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								R/sysdata.rda
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								R/sysdata.rda
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										4
									
								
								R/zzz.R
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								R/zzz.R
									
									
									
									
									
								
							| @@ -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 | ||||
|   | ||||
| @@ -103,10 +103,10 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) { | ||||
|     ) | ||||
|   ) | ||||
|  | ||||
|   # grouping in sir_calc_df() (= backbone of sir_sf()) | ||||
|   # grouping in sir_calc_df() (= backbone of sir_df()) | ||||
|   expect_true("ward" %in% (example_isolates %>% | ||||
|     group_by(ward) %>% | ||||
|     select(ward, AMX, CIP, gender) %>% | ||||
|     sir_sf() %>% | ||||
|     sir_df() %>% | ||||
|     colnames())) | ||||
| } | ||||
|   | ||||
| @@ -67,7 +67,7 @@ The function \code{\link[=count_resistant]{count_resistant()}} is equal to the f | ||||
|  | ||||
| The function \code{\link[=n_sir]{n_sir()}} is an alias of \code{\link[=count_all]{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 \code{n_distinct()}. Their function is equal to \code{count_susceptible(...) + count_resistant(...)}. | ||||
|  | ||||
| The function \code{\link[=count_df]{count_df()}} takes any variable from \code{data} that has an \code{\link{sir}} class (created with \code{\link[=as.sir]{as.sir()}}) and counts the number of S's, I's and R's. It also supports grouped variables. The function \code{\link[=sir_sf]{sir_sf()}} works exactly like \code{\link[=count_df]{count_df()}}, but adds the percentage of S, I and R. | ||||
| The function \code{\link[=count_df]{count_df()}} takes any variable from \code{data} that has an \code{\link{sir}} class (created with \code{\link[=as.sir]{as.sir()}}) and counts the number of S's, I's and R's. It also supports grouped variables. The function \code{\link[=sir_df]{sir_df()}} works exactly like \code{\link[=count_df]{count_df()}}, but adds the percentage of S, I and R. | ||||
| } | ||||
| \section{Interpretation of SIR}{ | ||||
|  | ||||
|   | ||||
| @@ -120,7 +120,7 @@ Use these functions to create bar plots for AMR data analysis. All functions rel | ||||
| At default, the names of antibiotics will be shown on the plots using \code{\link[=ab_name]{ab_name()}}. This can be set with the \code{translate_ab} argument. See \code{\link[=count_df]{count_df()}}. | ||||
| \subsection{The Functions}{ | ||||
|  | ||||
| \code{\link[=geom_sir]{geom_sir()}} will take any variable from the data that has an \code{\link{sir}} class (created with \code{\link[=as.sir]{as.sir()}}) using \code{\link[=sir_sf]{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. | ||||
| \code{\link[=geom_sir]{geom_sir()}} will take any variable from the data that has an \code{\link{sir}} class (created with \code{\link[=as.sir]{as.sir()}}) using \code{\link[=sir_df]{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. | ||||
|  | ||||
| \code{\link[=facet_sir]{facet_sir()}} creates 2d plots (at default based on S/I/R) using \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}}. | ||||
|  | ||||
|   | ||||
| @@ -12,7 +12,7 @@ | ||||
| \alias{proportion_SI} | ||||
| \alias{proportion_S} | ||||
| \alias{proportion_df} | ||||
| \alias{sir_sf} | ||||
| \alias{sir_df} | ||||
| \title{Calculate Microbial Resistance} | ||||
| \source{ | ||||
| \strong{M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 5th Edition}, 2022, \emph{Clinical and Laboratory Standards Institute (CLSI)}. \url{https://clsi.org/standards/products/microbiology/documents/m39/}. | ||||
| @@ -52,7 +52,7 @@ proportion_df( | ||||
|   confidence_level = 0.95 | ||||
| ) | ||||
|  | ||||
| sir_sf( | ||||
| sir_df( | ||||
|   data, | ||||
|   translate_ab = "name", | ||||
|   language = get_AMR_locale(), | ||||
| @@ -102,7 +102,7 @@ Use \code{\link[=sir_confidence_interval]{sir_confidence_interval()}} to calcula | ||||
|  | ||||
| These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the \code{\link[=count]{count()}} functions to count isolates. The function \code{\link[=susceptibility]{susceptibility()}} is essentially equal to \code{count_susceptible() / count_all()}. \emph{Low counts can influence the outcome - the \code{proportion} functions may camouflage this, since they only return the proportion (albeit being dependent on the \code{minimum} argument).} | ||||
|  | ||||
| The function \code{\link[=proportion_df]{proportion_df()}} takes any variable from \code{data} that has an \code{\link{sir}} class (created with \code{\link[=as.sir]{as.sir()}}) and calculates the proportions S, I, and R. It also supports grouped variables. The function \code{\link[=sir_sf]{sir_sf()}} works exactly like \code{\link[=proportion_df]{proportion_df()}}, but adds the number of isolates. | ||||
| The function \code{\link[=proportion_df]{proportion_df()}} takes any variable from \code{data} that has an \code{\link{sir}} class (created with \code{\link[=as.sir]{as.sir()}}) and calculates the proportions S, I, and R. It also supports grouped variables. The function \code{\link[=sir_df]{sir_df()}} works exactly like \code{\link[=proportion_df]{proportion_df()}}, but adds the number of isolates. | ||||
| } | ||||
| \section{Combination Therapy}{ | ||||
|  | ||||
| @@ -270,11 +270,11 @@ if (require("dplyr")) { | ||||
|     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) | ||||
| } | ||||
| } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user