1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-17 23:13:14 +02:00

count_* functions

This commit is contained in:
2018-08-22 00:02:26 +02:00
parent e47e77febc
commit 3e87c8f409
16 changed files with 504 additions and 59 deletions

View File

@ -3,11 +3,14 @@
\name{as.rsi}
\alias{as.rsi}
\alias{is.rsi}
\alias{is.rsi.eligible}
\title{Class 'rsi'}
\usage{
as.rsi(x)
is.rsi(x)
is.rsi.eligible(x)
}
\arguments{
\item{x}{vector}
@ -18,6 +21,9 @@ Ordered factor with new class \code{rsi} and new attribute \code{package}
\description{
This transforms a vector to a new class \code{rsi}, which is an ordered factor with levels \code{S < I < R}. Invalid antimicrobial interpretations will be translated as \code{NA} with a warning.
}
\details{
The function \code{is.rsi.eligible} returns \code{TRUE} when a columns contains only valid antimicrobial interpretations (S and/or I and/or R), and \code{FALSE} otherwise.
}
\examples{
rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370), "A", "B", "C"))
@ -29,6 +35,12 @@ as.rsi("<= 0.002; S") # will return S
plot(rsi_data) # for percentages
barplot(rsi_data) # for frequencies
freq(rsi_data) # frequency table with informative header
# fastest way to transform all columns with already valid AB results to class `rsi`:
library(dplyr)
septic_patients \%>\%
mutate_if(is.rsi.eligible,
as.rsi)
}
\seealso{
\code{\link{as.mic}}