AMR/man/as.rsi.Rd

66 lines
2.2 KiB
Plaintext
Raw Normal View History

2018-02-21 11:52:31 +01:00
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rsi.R
2018-02-21 11:52:31 +01:00
\name{as.rsi}
\alias{as.rsi}
\alias{is.rsi}
2018-08-22 00:02:26 +02:00
\alias{is.rsi.eligible}
2018-02-21 11:52:31 +01:00
\title{Class 'rsi'}
\usage{
as.rsi(x)
is.rsi(x)
2018-08-22 00:02:26 +02:00
2019-02-04 12:24:07 +01:00
is.rsi.eligible(x, threshold = 0.05)
2018-02-21 11:52:31 +01:00
}
\arguments{
\item{x}{vector}
2019-02-04 12:24:07 +01:00
\item{threshold}{maximum fraction of \code{x} that is allowed to fail transformation, see Examples}
2018-02-21 11:52:31 +01:00
}
\value{
2018-10-17 17:32:34 +02:00
Ordered factor with new class \code{rsi}
2018-02-21 11:52:31 +01:00
}
\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.
}
2018-08-22 00:02:26 +02:00
\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.
}
2019-01-02 23:24:07 +01:00
\section{Read more on our website!}{
\if{html}{\figure{logo.png}{options: height=40px style=margin-bottom:5px} \cr}
2019-01-29 20:20:09 +01:00
On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive 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}.
2019-01-02 23:24:07 +01:00
}
2018-02-21 11:52:31 +01:00
\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"))
2018-02-22 20:48:48 +01:00
is.rsi(rsi_data)
2018-03-14 09:58:58 +01:00
2018-06-19 10:05:38 +02:00
# this can also coerce combined MIC/RSI values:
as.rsi("<= 0.002; S") # will return S
2018-06-19 10:05:38 +02:00
2018-03-13 15:40:10 +01:00
plot(rsi_data) # for percentages
barplot(rsi_data) # for frequencies
2018-08-01 22:37:28 +02:00
freq(rsi_data) # frequency table with informative header
2018-08-22 00:02:26 +02:00
2018-12-07 12:04:55 +01:00
# using dplyr's mutate
2018-08-22 00:02:26 +02:00
library(dplyr)
2018-12-07 12:04:55 +01:00
septic_patients \%>\%
mutate_at(vars(peni:rifa), as.rsi)
2019-02-04 12:24:07 +01:00
2018-12-07 12:04:55 +01:00
# fastest way to transform all columns with already valid AB results to class `rsi`:
2018-08-22 00:02:26 +02:00
septic_patients \%>\%
mutate_if(is.rsi.eligible,
as.rsi)
2019-02-04 12:24:07 +01:00
# default threshold of `is.rsi.eligible` is 5\%.
is.rsi.eligible(WHONET$`First name`) # fails, >80\% is invalid
2019-02-04 18:04:29 +01:00
is.rsi.eligible(WHONET$`First name`, threshold = 0.9) # succeeds
2018-02-21 11:52:31 +01:00
}
\seealso{
\code{\link{as.mic}}
}
2018-07-13 17:23:46 +02:00
\keyword{rsi}