mirror of
https://github.com/msberends/AMR.git
synced 2025-07-11 10:21:54 +02:00
(v1.1.0.9005) lose dependencies
This commit is contained in:
68
man/count.Rd
68
man/count.Rd
@ -59,7 +59,7 @@ count_df(
|
||||
An \code{\link{integer}}
|
||||
}
|
||||
\description{
|
||||
These functions can be used to count resistant/susceptible microbial isolates. All functions support quasiquotation with pipes, can be used in \code{\link[=summarise]{summarise()}} and support grouped variables, see \emph{Examples}.
|
||||
These functions can be used to count resistant/susceptible microbial isolates. All functions support quasiquotation with pipes, can be used in \code{summarise()} from the \code{dplyr} package and also support grouped variables, please see \emph{Examples}.
|
||||
|
||||
\code{\link[=count_resistant]{count_resistant()}} should be used to count resistant isolates, \code{\link[=count_susceptible]{count_susceptible()}} should be used to count susceptible isolates.
|
||||
}
|
||||
@ -68,7 +68,7 @@ These functions are meant to count isolates. Use the \code{\link[=resistance]{re
|
||||
|
||||
The function \code{\link[=count_resistant]{count_resistant()}} is equal to the function \code{\link[=count_R]{count_R()}}. The function \code{\link[=count_susceptible]{count_susceptible()}} is equal to the function \code{\link[=count_SI]{count_SI()}}.
|
||||
|
||||
The function \code{\link[=n_rsi]{n_rsi()}} 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{\link[=n_distinct]{n_distinct()}}. Their function is equal to \code{count_susceptible(...) + count_resistant(...)}.
|
||||
The function \code{\link[=n_rsi]{n_rsi()}} 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{rsi}} class (created with \code{\link[=as.rsi]{as.rsi()}}) and counts the number of S's, I's and R's. It also supports grouped variables. The function \code{\link[=rsi_df]{rsi_df()}} works exactly like \code{\link[=count_df]{count_df()}}, but adds the percentage of S, I and R.
|
||||
}
|
||||
@ -157,38 +157,40 @@ n_rsi(example_isolates$AMX)
|
||||
count_susceptible(example_isolates$AMX)
|
||||
susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
|
||||
|
||||
library(dplyr)
|
||||
example_isolates \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(R = count_R(CIP),
|
||||
I = count_I(CIP),
|
||||
S = count_S(CIP),
|
||||
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!
|
||||
|
||||
# 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 `susceptibility()` calculates percentages right away instead.
|
||||
example_isolates \%>\% count_susceptible(AMC) # 1433
|
||||
example_isolates \%>\% count_all(AMC) # 1879
|
||||
|
||||
example_isolates \%>\% count_susceptible(GEN) # 1399
|
||||
example_isolates \%>\% count_all(GEN) # 1855
|
||||
|
||||
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)
|
||||
|
||||
# It also supports grouping variables
|
||||
example_isolates \%>\%
|
||||
select(hospital_id, AMX, CIP) \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
count_df(translate = FALSE)
|
||||
|
||||
if (!require("dplyr")) {
|
||||
example_isolates \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(R = count_R(CIP),
|
||||
I = count_I(CIP),
|
||||
S = count_S(CIP),
|
||||
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!
|
||||
|
||||
# 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 `susceptibility()` calculates percentages right away instead.
|
||||
example_isolates \%>\% count_susceptible(AMC) # 1433
|
||||
example_isolates \%>\% count_all(AMC) # 1879
|
||||
|
||||
example_isolates \%>\% count_susceptible(GEN) # 1399
|
||||
example_isolates \%>\% count_all(GEN) # 1855
|
||||
|
||||
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)
|
||||
|
||||
# It also supports grouping variables
|
||||
example_isolates \%>\%
|
||||
select(hospital_id, AMX, CIP) \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
count_df(translate = FALSE)
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=proportion]{proportion_*}} to calculate microbial resistance and susceptibility.
|
||||
|
Reference in New Issue
Block a user