NEWS.md
- Fix for printing class NA
Fix for mo_shortname()
when the input contains NA
If as.mo()
takes more than 30 seconds, some suggestions will be done to improve speed
Lost dependency on the tidyselect
package for using antibiotic selectors such as carbapenems()
and aminoglycosides()
Use these selection helpers inside any function that allows Tidyverse selection helpers, such as select()
and pivot_longer()
. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
These functions help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
ab_class(ab_class) @@ -282,7 +282,6 @@Details
All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.) in the antibiotics data set. This means that a selector like e.g.
-aminoglycosides()
will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.N.B. These functions require the
tidyselect
package to be installed, that comes with thedplyr
package. An error will be thrown if thetidyselect
package is not installed, or if the functions are used outside a function that allows Tidyverse selection helpers such asselect()
andpivot_longer()
`.Reference data publicly available
@@ -298,7 +297,15 @@
filter_ab_class()
for thefilter()
equivalent.Examples
-if (require("dplyr")) { +# `example_isolates` is a dataset available in the AMR package. +# See ?example_isolates. + +# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): +example_isolates[, c(carbapenems())] +# this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB': +example_isolates[, c("mo", aminoglycosides())] + +if (require("dplyr")) { # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): example_isolates %>% diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html index a8c2e140..ea173fc7 100644 --- a/docs/reference/eucast_rules.html +++ b/docs/reference/eucast_rules.html @@ -83,7 +83,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied
Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use is_new_episode()
that also supports grouping with the dplyr
package.
Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use is_new_episode()
that also supports grouping with the dplyr
package.
first_isolate( @@ -285,7 +285,7 @@x -+ a data.frame containing isolates. Can be omitted when used inside
dplyr
verbs, such asfilter()
,mutate()
andsummarise()
.a data.frame containing isolates. Can be left blank when used inside
dplyr
verbs, such asfilter()
,mutate()
andsummarise()
.col_date @@ -366,8 +366,8 @@A
logical
vectorDetails
-These functions are context-aware when used inside
-dplyr
verbs, such asfilter()
,mutate()
andsummarise()
. This means that then thex
argument can be omitted, please see Examples.The
+first_isolate()
function is a wrapper around theis_new_episode()
function, but more efficient for data sets containing microorganism codes or names.These functions are context-aware when used inside
+dplyr
verbs, such asfilter()
,mutate()
andsummarise()
. This means that then thex
argument can be left blank, please see Examples.The
first_isolate()
function is a wrapper around theis_new_episode()
function, but more efficient for data sets containing microorganism codes or names.All isolates with a microbial ID of
NA
will be excluded as first isolate.Why this is so important
diff --git a/docs/reference/get_episode.html b/docs/reference/get_episode.html index 2c7c1684..f780af55 100644 --- a/docs/reference/get_episode.html +++ b/docs/reference/get_episode.html @@ -82,7 +82,7 @@ diff --git a/docs/reference/index.html b/docs/reference/index.html index a338ac6b..85b27cb8 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index 93209875..6e95e09b 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -82,7 +82,7 @@ @@ -281,7 +281,7 @@x -+ a data.frame with antibiotics columns, like
AMX
oramox
. Can be omitted when used insidedplyr
verbs, such asfilter()
,mutate()
andsummarise()
.a data.frame with antibiotics columns, like
AMX
oramox
. Can be left blank when used insidedplyr
verbs, such asfilter()
,mutate()
andsummarise()
.col_mo @@ -331,7 +331,7 @@Details
-The
+key_antibiotics()
function is context-aware when used insidedplyr
verbs, such asfilter()
,mutate()
andsummarise()
. This means that then thex
argument can be omitted, please see Examples.The
key_antibiotics()
function is context-aware when used insidedplyr
verbs, such asfilter()
,mutate()
andsummarise()
. This means that then thex
argument can be left blank, please see Examples.The function
key_antibiotics()
returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared usingkey_antibiotics_equal()
, to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot ("."
) bykey_antibiotics()
and ignored bykey_antibiotics_equal()
.The
first_isolate()
function only uses this function on the same microbial species from the same patient. Using this, e.g. an MRSA will be included after a susceptible S. aureus (MSSA) is found within the same patient episode. Without key antibiotic comparison it would not. Seefirst_isolate()
for more info.At default, the antibiotics that are used for Gram-positive bacteria are:
diff --git a/docs/reference/mdro.html b/docs/reference/mdro.html index c30c713a..0bd0d11a 100644 --- a/docs/reference/mdro.html +++ b/docs/reference/mdro.html @@ -82,7 +82,7 @@
@@ -268,7 +268,7 @@x -+ a data.frame with antibiotics columns, like
AMX
oramox
. Can be omitted when used insidedplyr
verbs, such asfilter()
,mutate()
andsummarise()
.a data.frame with antibiotics columns, like
AMX
oramox
. Can be left blank when used insidedplyr
verbs, such asfilter()
,mutate()
andsummarise()
.guideline @@ -319,7 +319,7 @@ Ordered factor with levelsDetails - These functions are context-aware when used inside
+dplyr
verbs, such asfilter()
,mutate()
andsummarise()
. This means that then thex
argument can be omitted, please see Examples.These functions are context-aware when used inside
dplyr
verbs, such asfilter()
,mutate()
andsummarise()
. This means that then thex
argument can be left blank, please see Examples.For the
pct_required_classes
argument, values above 1 will be divided by 100. This is to support both fractions (0.75
or3/4
) and percentages (75
).Currently supported guidelines are (case-insensitive):
diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index 79617975..766dda35 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -82,7 +82,7 @@ @@ -301,7 +301,7 @@
guideline = "CMI2012"
(default)x -+ any character (vector) that can be coerced to a valid microorganism code with
as.mo()
. Can be omitted for auto-guessing the column containing microorganism codes when used insidedplyr
verbs, such asfilter()
,mutate()
andsummarise()
, please see Examples.any character (vector) that can be coerced to a valid microorganism code with
as.mo()
. Can be left blank for auto-guessing the column containing microorganism codes when used insidedplyr
verbs, such asfilter()
,mutate()
andsummarise()
, please see Examples.language diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index 31fdd23a..637bfe71 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -82,7 +82,7 @@ @@ -287,7 +287,7 @@x -+ a data.frame containing isolates. Can be omitted when used inside
dplyr
verbs, such asfilter()
,mutate()
andsummarise()
.a data.frame containing isolates. Can be left blank when used inside
dplyr
verbs, such asfilter()
,mutate()
andsummarise()
.col_ab diff --git a/docs/survey.html b/docs/survey.html index 56eb7252..37f991a2 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ diff --git a/man/antibiotic_class_selectors.Rd b/man/antibiotic_class_selectors.Rd index 89a8ab85..97f6d0a7 100644 --- a/man/antibiotic_class_selectors.Rd +++ b/man/antibiotic_class_selectors.Rd @@ -50,12 +50,10 @@ tetracyclines() \item{ab_class}{an antimicrobial class, like \code{"carbapenems"}. The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched (case-insensitive) for this value.} } \description{ -Use these selection helpers inside any function that allows \href{https://tidyselect.r-lib.org/reference/language.html}{Tidyverse selection helpers}, such as \code{\link[dplyr:select]{select()}} and \code{\link[tidyr:pivot_longer]{pivot_longer()}}. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. +These functions help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. } \details{ All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.) in the \link{antibiotics} data set. This means that a selector like e.g. \code{\link[=aminoglycosides]{aminoglycosides()}} will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. - -\strong{N.B. These functions require the \code{tidyselect} package to be installed}, that comes with the \code{dplyr} package. An error will be thrown if the \code{tidyselect} package is not installed, or if the functions are used outside a function that allows \href{https://tidyselect.r-lib.org/reference/language.html}{Tidyverse selection helpers} such as \code{\link[dplyr:select]{select()}} and \code{\link[tidyr:pivot_longer]{pivot_longer()}}`. } \section{Reference data publicly available}{ @@ -68,6 +66,14 @@ On our website \url{https://msberends.github.io/AMR/} you can find \href{https:/ } \examples{ +# `example_isolates` is a dataset available in the AMR package. +# See ?example_isolates. + +# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): +example_isolates[, c(carbapenems())] +# this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB': +example_isolates[, c("mo", aminoglycosides())] + if (require("dplyr")) { # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): diff --git a/man/first_isolate.Rd b/man/first_isolate.Rd index 80de1d67..b2a7bc87 100755 --- a/man/first_isolate.Rd +++ b/man/first_isolate.Rd @@ -50,7 +50,7 @@ filter_first_weighted_isolate( ) } \arguments{ -\item{x}{a \link{data.frame} containing isolates. Can be omitted when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} +\item{x}{a \link{data.frame} containing isolates. Can be left blank when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} \item{col_date}{column name of the result date (or date that is was received on the lab), defaults to the first column with a date class} @@ -93,7 +93,7 @@ A \code{\link{logical}} vector Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use \code{\link[=is_new_episode]{is_new_episode()}} that also supports grouping with the \code{dplyr} package. } \details{ -These functions are context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be omitted, please see \emph{Examples}. +These functions are context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be left blank, please see \emph{Examples}. The \code{\link[=first_isolate]{first_isolate()}} function is a wrapper around the \code{\link[=is_new_episode]{is_new_episode()}} function, but more efficient for data sets containing microorganism codes or names. diff --git a/man/key_antibiotics.Rd b/man/key_antibiotics.Rd index aedeebf3..4ada8def 100755 --- a/man/key_antibiotics.Rd +++ b/man/key_antibiotics.Rd @@ -40,7 +40,7 @@ key_antibiotics_equal( ) } \arguments{ -\item{x}{a \link{data.frame} with antibiotics columns, like \code{AMX} or \code{amox}. Can be omitted when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}.} +\item{x}{a \link{data.frame} with antibiotics columns, like \code{AMX} or \code{amox}. Can be left blank when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}.} \item{col_mo}{column name of the IDs of the microorganisms (see \code{\link[=as.mo]{as.mo()}}), defaults to the first column of class \code{\link{mo}}. Values will be coerced using \code{\link[=as.mo]{as.mo()}}.} @@ -68,7 +68,7 @@ key_antibiotics_equal( These function can be used to determine first isolates (see \code{\link[=first_isolate]{first_isolate()}}). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates can then be called first \emph{weighted} isolates. } \details{ -The \code{\link[=key_antibiotics]{key_antibiotics()}} function is context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be omitted, please see \emph{Examples}. +The \code{\link[=key_antibiotics]{key_antibiotics()}} function is context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be left blank, please see \emph{Examples}. The function \code{\link[=key_antibiotics]{key_antibiotics()}} returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared using \code{\link[=key_antibiotics_equal]{key_antibiotics_equal()}}, to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (\code{"."}) by \code{\link[=key_antibiotics]{key_antibiotics()}} and ignored by \code{\link[=key_antibiotics_equal]{key_antibiotics_equal()}}. diff --git a/man/mdro.Rd b/man/mdro.Rd index 0bc70dd8..01f056ef 100644 --- a/man/mdro.Rd +++ b/man/mdro.Rd @@ -40,7 +40,7 @@ mdr_cmi2012(x, guideline = "CMI2012", ...) eucast_exceptional_phenotypes(x, guideline = "EUCAST", ...) } \arguments{ -\item{x}{a \link{data.frame} with antibiotics columns, like \code{AMX} or \code{amox}. Can be omitted when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} +\item{x}{a \link{data.frame} with antibiotics columns, like \code{AMX} or \code{amox}. Can be left blank when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} \item{guideline}{a specific guideline to follow. When left empty, the publication by Magiorakos \emph{et al.} (2012, Clinical Microbiology and Infection) will be followed, please see \emph{Details}.} @@ -72,7 +72,7 @@ Ordered \link{factor} with levels \code{Negative} < \verb{Positive, unconfirmed} Determine which isolates are multidrug-resistant organisms (MDRO) according to international and national guidelines. } \details{ -These functions are context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be omitted, please see \emph{Examples}. +These functions are context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be left blank, please see \emph{Examples}. For the \code{pct_required_classes} argument, values above 1 will be divided by 100. This is to support both fractions (\code{0.75} or \code{3/4}) and percentages (\code{75}). diff --git a/man/mo_property.Rd b/man/mo_property.Rd index 42b6cf33..8dd1cb03 100644 --- a/man/mo_property.Rd +++ b/man/mo_property.Rd @@ -85,7 +85,7 @@ mo_url(x, open = FALSE, language = get_locale(), ...) mo_property(x, property = "fullname", language = get_locale(), ...) } \arguments{ -\item{x}{any character (vector) that can be coerced to a valid microorganism code with \code{\link[=as.mo]{as.mo()}}. Can be omitted for auto-guessing the column containing microorganism codes when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}, please see \emph{Examples}.} +\item{x}{any character (vector) that can be coerced to a valid microorganism code with \code{\link[=as.mo]{as.mo()}}. Can be left blank for auto-guessing the column containing microorganism codes when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}, please see \emph{Examples}.} \item{language}{language of the returned text, defaults to system language (see \code{\link[=get_locale]{get_locale()}}) and can be overwritten by setting the option \code{AMR_locale}, e.g. \code{options(AMR_locale = "de")}, see \link{translate}. Also used to translate text like "no growth". Use \code{language = NULL} or \code{language = ""} to prevent translation.} diff --git a/man/resistance_predict.Rd b/man/resistance_predict.Rd index 6fec8877..00bce888 100644 --- a/man/resistance_predict.Rd +++ b/man/resistance_predict.Rd @@ -47,7 +47,7 @@ ggplot_rsi_predict( ) } \arguments{ -\item{x}{a \link{data.frame} containing isolates. Can be omitted when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} +\item{x}{a \link{data.frame} containing isolates. Can be left blank when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} \item{col_ab}{column name of \code{x} containing antimicrobial interpretations (\code{"R"}, \code{"I"} and \code{"S"})} diff --git a/tests/testthat/test-zzz.R b/tests/testthat/test-zzz.R index a62f707f..30500af1 100644 --- a/tests/testthat/test-zzz.R +++ b/tests/testthat/test-zzz.R @@ -51,7 +51,6 @@ test_that("imports work", { "insertText" = "rstudioapi", "left_join" = "dplyr", "new_pillar_shaft_simple" = "pillar", - "peek_vars" = "tidyselect", "read_excel" = "readxl", "read_html" = "xml2", "right_join" = "dplyr",