mirror of
https://github.com/msberends/AMR.git
synced 2025-09-06 04:09:39 +02:00
(v1.5.0.9032) All group generics for MICs
This commit is contained in:
@@ -11,18 +11,50 @@ as.mic(x, na.rm = FALSE)
|
||||
is.mic(x)
|
||||
}
|
||||
\arguments{
|
||||
\item{x}{vector}
|
||||
\item{x}{character or numeric vector}
|
||||
|
||||
\item{na.rm}{a logical indicating whether missing values should be removed}
|
||||
}
|
||||
\value{
|
||||
Ordered \link{factor} with additional class \code{\link{mic}}
|
||||
Ordered \link{factor} with additional class \code{\link{mic}}, that in mathematical operations acts as decimal numbers. Bare in mind that the outcome of any mathematical operation on MICs will return a numeric value.
|
||||
}
|
||||
\description{
|
||||
This transforms a vector to a new class \code{\link{mic}}, which is an ordered \link{factor} with valid minimum inhibitory concentrations (MIC) as levels. Invalid MIC values will be translated as \code{NA} with a warning.
|
||||
This ransforms vectors to a new class \code{\link{mic}}, which treats the input as decimal numbers, while maintaining operators (such as ">=") and only allowing valid MIC values known to the field of (medical) microbiology.
|
||||
}
|
||||
\details{
|
||||
To interpret MIC values as RSI values, use \code{\link[=as.rsi]{as.rsi()}} on MIC values. It supports guidelines from EUCAST and CLSI.
|
||||
|
||||
This class for MIC values is a quite a special data type: formally it is an ordered factor with valid MIC values as factor levels (to make sure only valid MIC values are retained), but for any mathematical operation it acts as decimal numbers:\preformatted{x <- random_mic(10)
|
||||
x
|
||||
#> Class <mic>
|
||||
#> [1] 16 1 8 8 64 >=128 0.0625 32 32 16
|
||||
|
||||
is.factor(x)
|
||||
#> [1] TRUE
|
||||
|
||||
x[1] * 2
|
||||
#> [1] 32
|
||||
|
||||
median(x)
|
||||
#> [1] 26
|
||||
}
|
||||
|
||||
This makes it possible to maintain operators that often come with MIC values, such ">=" and "<=", even when filtering using numeric values in data analysis, e.g.:\preformatted{x[x > 4]
|
||||
#> Class <mic>
|
||||
#> [1] 16 8 8 64 >=128 32 32 16
|
||||
|
||||
df <- data.frame(x, hospital = "A")
|
||||
subset(df, x > 4) # or with dplyr: df \%>\% filter(x > 4)
|
||||
#> x hospital
|
||||
#> 1 16 A
|
||||
#> 5 64 A
|
||||
#> 6 >=128 A
|
||||
#> 8 32 A
|
||||
#> 9 32 A
|
||||
#> 10 16 A
|
||||
}
|
||||
|
||||
The following \link[=groupGeneric]{generic functions} are implemented for the MIC class: \code{!}, \code{!=}, \code{\%\%}, \code{\%/\%}, \code{&}, \code{*}, \code{+}, \code{-}, \code{/}, \code{<}, \code{<=}, \code{==}, \code{>}, \code{>=}, \code{^}, \code{|}, \code{\link[=abs]{abs()}}, \code{\link[=acos]{acos()}}, \code{\link[=acosh]{acosh()}}, \code{\link[=all]{all()}}, \code{\link[=any]{any()}}, \code{\link[=asin]{asin()}}, \code{\link[=asinh]{asinh()}}, \code{\link[=atan]{atan()}}, \code{\link[=atanh]{atanh()}}, \code{\link[=ceiling]{ceiling()}}, \code{\link[=cos]{cos()}}, \code{\link[=cosh]{cosh()}}, \code{\link[=cospi]{cospi()}}, \code{\link[=cummax]{cummax()}}, \code{\link[=cummin]{cummin()}}, \code{\link[=cumprod]{cumprod()}}, \code{\link[=cumsum]{cumsum()}}, \code{\link[=digamma]{digamma()}}, \code{\link[=exp]{exp()}}, \code{\link[=expm1]{expm1()}}, \code{\link[=floor]{floor()}}, \code{\link[=gamma]{gamma()}}, \code{\link[=lgamma]{lgamma()}}, \code{\link[=log]{log()}}, \code{\link[=log10]{log10()}}, \code{\link[=log1p]{log1p()}}, \code{\link[=log2]{log2()}}, \code{\link[=max]{max()}}, \code{\link[=mean]{mean()}}, \code{\link[=median]{median()}}, \code{\link[=min]{min()}}, \code{\link[=prod]{prod()}}, \code{\link[=quantile]{quantile()}}, \code{\link[=range]{range()}}, \code{\link[=round]{round()}}, \code{\link[=sign]{sign()}}, \code{\link[=signif]{signif()}}, \code{\link[=sin]{sin()}}, \code{\link[=sinh]{sinh()}}, \code{\link[=sinpi]{sinpi()}}, \code{\link[=sqrt]{sqrt()}}, \code{\link[=sum]{sum()}}, \code{\link[=tan]{tan()}}, \code{\link[=tanh]{tanh()}}, \code{\link[=tanpi]{tanpi()}}, \code{\link[=trigamma]{trigamma()}} and \code{\link[=trunc]{trunc()}}.
|
||||
}
|
||||
\section{Stable Lifecycle}{
|
||||
|
||||
|
Reference in New Issue
Block a user