1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 02:03:04 +02:00

(v0.8.0.9027) adding susceptibility() and resistance()

This commit is contained in:
2019-11-10 12:16:56 +01:00
parent 228a4245cb
commit 59ededa8dc
85 changed files with 1526 additions and 932 deletions

View File

@ -2,13 +2,25 @@
% Please edit documentation in R/deprecated.R
\name{AMR-deprecated}
\alias{AMR-deprecated}
\alias{as.atc}
\alias{p.symbol}
\alias{portion_R}
\alias{portion_IR}
\alias{portion_I}
\alias{portion_SI}
\alias{portion_S}
\title{Deprecated functions}
\usage{
as.atc(x)
p.symbol(...)
portion_R(...)
portion_IR(...)
portion_I(...)
portion_SI(...)
portion_S(...)
}
\description{
These functions are so-called '\link{Deprecated}'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).

View File

@ -13,28 +13,19 @@ We created this package for both academic research and routine analysis at the F
This package can be used for:
\itemize{
\item{Reference for microorganisms, since it contains all microbial (sub)species from the Catalogue of Life}
\item{Reference for the taxonomy of microorganisms, since the package contains all microbial (sub)species from the Catalogue of Life}
\item{Interpreting raw MIC and disk diffusion values, based on the latest CLSI or EUCAST guidelines}
\item{Determining first isolates to be used for AMR analysis}
\item{Calculating antimicrobial resistance}
\item{Determining multi-drug resistance (MDR) / multi-drug resistant organisms (MDRO)}
\item{Calculating empirical susceptibility of both mono therapy and combination therapy}
\item{Calculating (empirical) susceptibility of both mono therapy and combination therapies}
\item{Predicting future antimicrobial resistance using regression models}
\item{Getting properties for any microorganism (like Gram stain, species, genus or family)}
\item{Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name)}
\item{Getting properties for any antibiotic (like name, EARS-Net code, ATC code, PubChem code, defined daily dose or trade name)}
\item{Plotting antimicrobial resistance}
\item{Determining first isolates to be used for AMR analysis}
\item{Applying EUCAST expert rules}
\item{Descriptive statistics: frequency tables, kurtosis and skewness}
}
}
\section{Authors}{
Matthijs S. Berends[1,2] Christian F. Luz[1], Erwin E.A. Hassing[2], Corinna Glasner[1], Alex W. Friedrich[1], Bhanu N.M. Sinha[1] \cr
[1] Department of Medical Microbiology, University of Groningen, University Medical Center Groningen, Groningen, the Netherlands - \url{https://www.rug.nl} \url{https://www.umcg.nl} \cr
[2] Certe Medical Diagnostics & Advice, Groningen, the Netherlands - \url{https://www.certe.nl}
}
\section{Read more on our website!}{
On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}.

View File

@ -63,7 +63,7 @@ In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
This AMR package honours this new insight. Use \code{\link{susceptibility}} (equal to \code{\link{proportion_SI}}) to determine antimicrobial susceptibility and \code{\link{count_susceptible}} (equal to \code{\link{count_SI}}) to count susceptible isolates.
}
\section{Read more on our website!}{

View File

@ -15,10 +15,10 @@ availability(tbl, width = NULL)
\code{data.frame} with column names of \code{tbl} as row names
}
\description{
Easy check for availability of columns in a data set. This makes it easy to get an idea of which antimicrobial combination can be used for calculation with e.g. \code{\link{portion_R}}.
Easy check for availability of columns in a data set. This makes it easy to get an idea of which antimicrobial combination can be used for calculation with e.g. \code{\link{resistance}}.
}
\details{
The function returns a \code{data.frame} with columns \code{"resistant"} and \code{"visual_resistance"}. The values in that columns are calculated with \code{\link{portion_R}}.
The function returns a \code{data.frame} with columns \code{"resistant"} and \code{"visual_resistance"}. The values in that columns are calculated with \code{\link{resistance}}.
}
\section{Read more on our website!}{

View File

@ -2,6 +2,8 @@
% Please edit documentation in R/count.R
\name{count}
\alias{count}
\alias{count_resistant}
\alias{count_susceptible}
\alias{count_R}
\alias{count_IR}
\alias{count_I}
@ -11,10 +13,11 @@
\alias{n_rsi}
\alias{count_df}
\title{Count isolates}
\source{
Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html}
}
\usage{
count_resistant(..., only_all_tested = FALSE)
count_susceptible(..., only_all_tested = FALSE)
count_R(..., only_all_tested = FALSE)
count_IR(..., only_all_tested = FALSE)
@ -53,16 +56,16 @@ Integer
\description{
These functions can be used to count resistant/susceptible microbial isolates. All functions support quasiquotation with pipes, can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
\code{count_R} and \code{count_IR} can be used to count resistant isolates, \code{count_S} and \code{count_SI} can be used to count susceptible isolates.\cr
\code{count_resistant} should be used to count resistant isolates, \code{count_susceptible} should be used to count susceptible isolates.\cr
}
\details{
These functions are meant to count isolates. Use the \code{\link{portion}_*} functions to calculate microbial resistance.
These functions are meant to count isolates. Use the \code{\link{resistance}}/\code{\link{susceptibility}} functions to calculate microbial resistance/susceptibility.
The function \code{n_rsi} is an alias of \code{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{\link{n_distinct}}. Their function is equal to \code{count_S(...) + count_IR(...)}.
The function \code{count_resistant} is equal to the function \code{count_R}. The function \code{count_susceptible} is equal to the function \code{count_SI}.
The function \code{count_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and counts the amounts of S, I and R. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each variable with class \code{"rsi"}.
The function \code{n_rsi} is an alias of \code{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{\link{n_distinct}}. Their function is equal to \code{count_susceptible(...) + count_resistant(...)}.
The function \code{rsi_df} works exactly like \code{count_df}, but adds the percentage of S, I and R.
The function \code{count_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and counts the number of S's, I's and R's. The function \code{rsi_df} works exactly like \code{count_df}, but adds the percentage of S, I and R.
}
\section{Interpretation of S, I and R}{
@ -76,12 +79,12 @@ In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
This AMR package honours this new insight. Use \code{\link{susceptibility}} (equal to \code{\link{proportion_SI}}) to determine antimicrobial susceptibility and \code{\link{count_susceptible}} (equal to \code{\link{count_SI}}) to count susceptible isolates.
}
\section{Combination therapy}{
When using more than one variable for \code{...} (= combination therapy)), use \code{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, Antibiotic A and Antibiotic B, about how \code{portion_SI} works to calculate the \%SI:
When using more than one variable for \code{...} (= combination therapy)), use \code{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, Antibiotic A and Antibiotic B, about how \code{susceptibility} works to calculate the \%SI:
\preformatted{
--------------------------------------------------------------------
@ -104,13 +107,13 @@ When using more than one variable for \code{...} (= combination therapy)), use \
Please note that, in combination therapies, for \code{only_all_tested = TRUE} applies that:
\preformatted{
count_S() + count_I() + count_R() == count_all()
portion_S() + portion_I() + portion_R() == 1
count_S() + count_I() + count_R() = count_all()
proportion_S() + proportion_I() + proportion_R() = 1
}
and that, in combination therapies, for \code{only_all_tested = FALSE} applies that:
\preformatted{
count_S() + count_I() + count_R() >= count_all()
portion_S() + portion_I() + portion_R() >= 1
count_S() + count_I() + count_R() >= count_all()
proportion_S() + proportion_I() + proportion_R() >= 1
}
Using \code{only_all_tested} has no impact when only using one antibiotic as input.
@ -125,23 +128,27 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
# example_isolates is a data set available in the AMR package.
?example_isolates
# Count resistant isolates
count_R(example_isolates$AMX)
count_IR(example_isolates$AMX)
count_resistant(example_isolates$AMX) # counts "R"
count_susceptible(example_isolates$AMX) # counts "S" and "I"
count_all(example_isolates$AMX) # counts "S", "I" and "R"
# Or susceptible isolates
# be more specific
count_S(example_isolates$AMX)
count_SI(example_isolates$AMX)
count_I(example_isolates$AMX)
count_IR(example_isolates$AMX)
count_R(example_isolates$AMX)
# Count all available isolates
count_all(example_isolates$AMX)
n_rsi(example_isolates$AMX)
# Since n_rsi counts available isolates, you can
# calculate back to count e.g. non-susceptible isolates.
# This results in the same:
count_SI(example_isolates$AMX)
portion_SI(example_isolates$AMX) * n_rsi(example_isolates$AMX)
# n_rsi() is an alias of count_all().
# Since it counts all available isolates, you can
# calculate back to count e.g. susceptible isolates.
# These results are the same:
count_susceptible(example_isolates$AMX)
susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
library(dplyr)
example_isolates \%>\%
@ -155,19 +162,16 @@ example_isolates \%>\%
# Count co-resistance between amoxicillin/clav acid and gentamicin,
# so we can see that combination therapy does a lot more than mono therapy.
# Please mind that `portion_SI` calculates percentages right away instead.
count_SI(example_isolates$AMC) # 1433
count_all(example_isolates$AMC) # 1879
# Please mind that `susceptibility()` calculates percentages right away instead.
example_isolates \%>\% count_susceptible(AMC) # 1433
example_isolates \%>\% count_all(AMC) # 1879
count_SI(example_isolates$GEN) # 1399
count_all(example_isolates$GEN) # 1855
example_isolates \%>\% count_susceptible(GEN) # 1399
example_isolates \%>\% count_all(GEN) # 1855
with(example_isolates,
count_SI(AMC, GEN)) # 1764
with(example_isolates,
n_rsi(AMC, GEN)) # 1936
# Get portions S/I/R immediately of all rsi columns
example_isolates \%>\% count_susceptible(AMC, GEN) # 1764
example_isolates \%>\% count_all(AMC, GEN) # 1936
# Get number of S+I vs. R immediately of selected columns
example_isolates \%>\%
select(AMX, CIP) \%>\%
count_df(translate = FALSE)
@ -180,5 +184,5 @@ example_isolates \%>\%
}
\seealso{
\code{\link{portion}_*} to calculate microbial resistance and susceptibility.
\code{\link{proportion}_*} to calculate microbial resistance and susceptibility.
}

View File

@ -41,7 +41,7 @@ labels_rsi_count(position = NULL, x = "antibiotic",
\arguments{
\item{data}{a \code{data.frame} with column(s) of class \code{"rsi"} (see \code{\link{as.rsi}})}
\item{position}{position adjustment of bars, either \code{"fill"} (default when \code{fun} is \code{\link{count_df}}), \code{"stack"} (default when \code{fun} is \code{\link{portion_df}}) or \code{"dodge"}}
\item{position}{position adjustment of bars, either \code{"fill"}, \code{"stack"} or \code{"dodge"}}
\item{x}{variable to show on x axis, either \code{"antibiotic"} (default) or \code{"interpretation"} or a grouping variable}
@ -131,7 +131,7 @@ example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi()
# get only portions and no counts:
# get only proportions and no counts:
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi(datalabels = FALSE)

View File

@ -175,7 +175,7 @@ In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
This AMR package honours this new insight. Use \code{\link{susceptibility}} (equal to \code{\link{proportion_SI}}) to determine antimicrobial susceptibility and \code{\link{count_susceptible}} (equal to \code{\link{count_SI}}) to count susceptible isolates.
}
\section{Read more on our website!}{

View File

@ -1,37 +1,44 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/portion.R, R/rsi_df.R
\name{portion}
% Please edit documentation in R/proportion.R, R/rsi_df.R
\name{proportion}
\alias{proportion}
\alias{resistance}
\alias{portion}
\alias{portion_R}
\alias{portion_IR}
\alias{portion_I}
\alias{portion_SI}
\alias{portion_S}
\alias{portion_df}
\alias{susceptibility}
\alias{proportion_R}
\alias{proportion_IR}
\alias{proportion_I}
\alias{proportion_SI}
\alias{proportion_S}
\alias{proportion_df}
\alias{rsi_df}
\title{Calculate resistance of isolates}
\title{Calculate microbial resistance}
\source{
\strong{M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition}, 2014, \emph{Clinical and Laboratory Standards Institute (CLSI)}. \url{https://clsi.org/standards/products/microbiology/documents/m39/}.
Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html}
}
\usage{
portion_R(..., minimum = 30, as_percent = FALSE,
resistance(..., minimum = 30, as_percent = FALSE,
only_all_tested = FALSE)
portion_IR(..., minimum = 30, as_percent = FALSE,
susceptibility(..., minimum = 30, as_percent = FALSE,
only_all_tested = FALSE)
portion_I(..., minimum = 30, as_percent = FALSE,
proportion_R(..., minimum = 30, as_percent = FALSE,
only_all_tested = FALSE)
portion_SI(..., minimum = 30, as_percent = FALSE,
proportion_IR(..., minimum = 30, as_percent = FALSE,
only_all_tested = FALSE)
portion_S(..., minimum = 30, as_percent = FALSE,
proportion_I(..., minimum = 30, as_percent = FALSE,
only_all_tested = FALSE)
portion_df(data, translate_ab = "name", language = get_locale(),
proportion_SI(..., minimum = 30, as_percent = FALSE,
only_all_tested = FALSE)
proportion_S(..., minimum = 30, as_percent = FALSE,
only_all_tested = FALSE)
proportion_df(data, translate_ab = "name", language = get_locale(),
minimum = 30, as_percent = FALSE, combine_SI = TRUE,
combine_IR = FALSE)
@ -62,22 +69,22 @@ rsi_df(data, translate_ab = "name", language = get_locale(),
Double or, when \code{as_percent = TRUE}, a character.
}
\description{
These functions can be used to calculate the (co-)resistance of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
These functions can be used to calculate the (co-)resistance or susceptibility of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
\code{portion_R} and \code{portion_IR} can be used to calculate resistance, \code{portion_S} and \code{portion_SI} can be used to calculate susceptibility.\cr
\code{resistance} should be used to calculate resistance, \code{susceptibility} should be used to calculate susceptibility.\cr
}
\details{
The function \code{resistance} is equal to the function \code{proportion_R}. The function \code{susceptibility} is equal to the function \code{proportion_SI}.
\strong{Remember that you should filter your table to let it contain only first isolates!} This is needed to exclude duplicates and to reduce selection bias. Use \code{\link{first_isolate}} to determine them in your data set.
These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. The function \code{portion_SI()} is essentially equal to \code{count_SI() / count_all()}. \emph{Low counts can infuence the outcome - the \code{portion} functions may camouflage this, since they only return the portion (albeit being dependent on the \code{minimum} parameter).}
These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. The function \code{susceptibility()} is essentially equal to \code{count_susceptible() / count_all()}. \emph{Low counts can infuence the outcome - the \code{proportion} functions may camouflage this, since they only return the proportion (albeit being dependent on the \code{minimum} parameter).}
The function \code{portion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the portions R, I and S. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each group and each variable with class \code{"rsi"}.
The function \code{rsi_df} works exactly like \code{portion_df}, but adds the number of isolates.
The function \code{proportion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the proportions R, I and S. The function \code{rsi_df} works exactly like \code{proportion_df}, but adds the number of isolates.
}
\section{Combination therapy}{
When using more than one variable for \code{...} (= combination therapy)), use \code{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, Antibiotic A and Antibiotic B, about how \code{portion_SI} works to calculate the \%SI:
When using more than one variable for \code{...} (= combination therapy)), use \code{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, Antibiotic A and Antibiotic B, about how \code{susceptibility} works to calculate the \%SI:
\preformatted{
--------------------------------------------------------------------
@ -100,13 +107,13 @@ When using more than one variable for \code{...} (= combination therapy)), use \
Please note that, in combination therapies, for \code{only_all_tested = TRUE} applies that:
\preformatted{
count_S() + count_I() + count_R() == count_all()
portion_S() + portion_I() + portion_R() == 1
count_S() + count_I() + count_R() = count_all()
proportion_S() + proportion_I() + proportion_R() = 1
}
and that, in combination therapies, for \code{only_all_tested = FALSE} applies that:
\preformatted{
count_S() + count_I() + count_R() >= count_all()
portion_S() + portion_I() + portion_R() >= 1
count_S() + count_I() + count_R() >= count_all()
proportion_S() + proportion_I() + proportion_R() >= 1
}
Using \code{only_all_tested} has no impact when only using one antibiotic as input.
@ -124,7 +131,7 @@ In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
This AMR package honours this new insight. Use \code{\link{susceptibility}} (equal to \code{\link{proportion_SI}}) to determine antimicrobial susceptibility and \code{\link{count_susceptible}} (equal to \code{\link{count_SI}}) to count susceptible isolates.
}
\section{Read more on our website!}{
@ -136,81 +143,72 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
# example_isolates is a data set available in the AMR package.
?example_isolates
# Calculate resistance
portion_R(example_isolates$AMX)
portion_IR(example_isolates$AMX)
resistance(example_isolates$AMX) # determines \%R
susceptibility(example_isolates$AMX) # determines \%S+I
# Or susceptibility
portion_S(example_isolates$AMX)
portion_SI(example_isolates$AMX)
# be more specific
proportion_S(example_isolates$AMX)
proportion_SI(example_isolates$AMX)
proportion_I(example_isolates$AMX)
proportion_IR(example_isolates$AMX)
proportion_R(example_isolates$AMX)
# Do the above with pipes:
library(dplyr)
example_isolates \%>\% portion_R(AMX)
example_isolates \%>\% portion_IR(AMX)
example_isolates \%>\% portion_S(AMX)
example_isolates \%>\% portion_SI(AMX)
example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(r = resistance(CIP),
n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr, see ?n_rsi
example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(p = portion_SI(CIP),
n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr
example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(R = portion_R(CIP, as_percent = TRUE),
I = portion_I(CIP, as_percent = TRUE),
S = portion_S(CIP, as_percent = TRUE),
summarise(R = resistance(CIP, as_percent = TRUE),
SI = susceptibility(CIP, as_percent = TRUE),
n1 = count_all(CIP), # the actual total; sum of all three
n2 = n_rsi(CIP), # same - analogous to n_distinct
total = n()) # NOT the number of tested isolates!
# Calculate co-resistance between amoxicillin/clav acid and gentamicin,
# so we can see that combination therapy does a lot more than mono therapy:
example_isolates \%>\% portion_SI(AMC) # \%SI = 76.3\%
example_isolates \%>\% susceptibility(AMC) # \%SI = 76.3\%
example_isolates \%>\% count_all(AMC) # n = 1879
example_isolates \%>\% portion_SI(GEN) # \%SI = 75.4\%
example_isolates \%>\% susceptibility(GEN) # \%SI = 75.4\%
example_isolates \%>\% count_all(GEN) # n = 1855
example_isolates \%>\% portion_SI(AMC, GEN) # \%SI = 94.1\%
example_isolates \%>\% count_all(AMC, GEN) # n = 1939
example_isolates \%>\% susceptibility(AMC, GEN) # \%SI = 94.1\%
example_isolates \%>\% count_all(AMC, GEN) # n = 1939
# See Details on how `only_all_tested` works. Example:
example_isolates \%>\%
summarise(numerator = count_SI(AMC, GEN),
summarise(numerator = count_susceptible(AMC, GEN),
denominator = count_all(AMC, GEN),
portion = portion_SI(AMC, GEN))
# numerator denominator portion
# 1764 1936 0.9408
proportion = susceptibility(AMC, GEN))
example_isolates \%>\%
summarise(numerator = count_SI(AMC, GEN, only_all_tested = TRUE),
summarise(numerator = count_susceptible(AMC, GEN, only_all_tested = TRUE),
denominator = count_all(AMC, GEN, only_all_tested = TRUE),
portion = portion_SI(AMC, GEN, only_all_tested = TRUE))
# numerator denominator portion
# 1687 1798 0.9383
proportion = susceptibility(AMC, GEN, only_all_tested = TRUE))
example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(cipro_p = portion_SI(CIP, as_percent = TRUE),
summarise(cipro_p = susceptibility(CIP, as_percent = TRUE),
cipro_n = count_all(CIP),
genta_p = portion_SI(GEN, as_percent = TRUE),
genta_p = susceptibility(GEN, as_percent = TRUE),
genta_n = count_all(GEN),
combination_p = portion_SI(CIP, GEN, as_percent = TRUE),
combination_p = susceptibility(CIP, GEN, as_percent = TRUE),
combination_n = count_all(CIP, GEN))
# Get portions S/I/R immediately of all rsi columns
# Get proportions S/I/R immediately of all rsi columns
example_isolates \%>\%
select(AMX, CIP) \%>\%
portion_df(translate = FALSE)
proportion_df(translate = FALSE)
# It also supports grouping variables
example_isolates \%>\%
select(hospital_id, AMX, CIP) \%>\%
group_by(hospital_id) \%>\%
portion_df(translate = FALSE)
proportion_df(translate = FALSE)
\dontrun{
@ -219,7 +217,7 @@ example_isolates \%>\%
my_table \%>\%
filter(first_isolate == TRUE,
genus == "Helicobacter") \%>\%
summarise(p = portion_S(AMX, MTR), # amoxicillin with metronidazole
summarise(p = susceptibility(AMX, MTR), # amoxicillin with metronidazole
n = count_all(AMX, MTR))
}
}