From 7b42b15c905f68f5408de6ae94088b999367ca1e Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Tue, 24 Nov 2020 11:47:54 +0100 Subject: [PATCH] (v1.4.0.9026) docu update --- DESCRIPTION | 4 ++-- NEWS.md | 4 ++-- R/first_isolate.R | 4 ++-- R/ggplot_rsi.R | 5 ++--- R/globals.R | 1 + R/is_new_episode.R | 20 +++++++------------- docs/404.html | 2 +- docs/LICENSE-text.html | 2 +- docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 12 ++++++------ docs/pkgdown.yml | 2 +- docs/reference/first_isolate.html | 6 +++--- docs/reference/ggplot_rsi.html | 7 +++---- docs/reference/index.html | 2 +- docs/reference/is_new_episode.html | 7 ++++++- docs/survey.html | 2 +- man/first_isolate.Rd | 4 ++-- man/ggplot_rsi.Rd | 5 ++--- man/is_new_episode.Rd | 2 +- 21 files changed, 47 insertions(+), 50 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 15007eb9..47208556 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.4.0.9025 -Date: 2020-11-23 +Version: 1.4.0.9026 +Date: 2020-11-24 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index aeae4f47..cee74a51 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.4.0.9025 -## Last updated: 23 November 2020 +# AMR 1.4.0.9026 +## Last updated: 24 November 2020 ### New * Function `is_new_episode()` to determine patient episodes which are not necessarily based on microorganisms. It also supports grouped variables with e.g. `mutate()`, `filter()` and `summarise()` of the `dplyr` package: diff --git a/R/first_isolate.R b/R/first_isolate.R index 7ed2c1f8..c4c2d3b7 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -27,7 +27,7 @@ #' #' 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. #' @inheritSection lifecycle Stable lifecycle -#' @param x,.data a [data.frame] containing isolates. +#' @param x a [data.frame] containing isolates. #' @param 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 #' @param col_patient_id column name of the unique IDs of the patients, defaults to the first column that starts with 'patient' or 'patid' (case insensitive) #' @param col_mo column name of the IDs of the microorganisms (see [as.mo()]), defaults to the first column of class [`mo`]. Values will be coerced using [as.mo()]. @@ -44,7 +44,7 @@ #' @param points_threshold points until the comparison of key antibiotics will lead to inclusion of an isolate when `type = "points"`, see Details #' @param info print progress #' @param include_unknown logical to determine whether 'unknown' microorganisms should be included too, i.e. microbial code `"UNKNOWN"`, which defaults to `FALSE`. For WHONET users, this means that all records with organism code `"con"` (*contamination*) will be excluded at default. Isolates with a microbial ID of `NA` will always be excluded as first isolate. -#' @param ... parameters passed on to the [first_isolate()] function +#' @param ... parameters passed on to [first_isolate()] when using [filter_first_isolate()], or parameters passed on to [key_antibiotics()] when using [filter_first_weighted_isolate()] #' @details The [first_isolate()] function is a wrapper around the [is_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. diff --git a/R/ggplot_rsi.R b/R/ggplot_rsi.R index cbcf7fe9..a378280f 100755 --- a/R/ggplot_rsi.R +++ b/R/ggplot_rsi.R @@ -36,7 +36,7 @@ #' @param facet variable to split plots by, either `"interpretation"` (default) or `"antibiotic"` or a grouping variable #' @inheritParams proportion #' @param nrow (when using `facet`) number of rows -#' @param colours a named vector with colours for the bars. The names must be one or more of: S, SI, I, IR, R or be `FALSE` to use default [ggplot2][[ggplot2::ggplot()] colours. +#' @param colours a named vector with colours for the bars. The names must be one or more of: S, SI, I, IR, R or be `FALSE` to use default [ggplot2][ggplot2::ggplot()] colours. #' @param datalabels show datalabels using [labels_rsi_count()] #' @param datalabels.size size of the datalabels #' @param datalabels.colour colour of the datalabels @@ -107,13 +107,12 @@ #' } #' #' \donttest{ -#' #' # resistance of ciprofloxacine per age group #' example_isolates %>% #' mutate(first_isolate = first_isolate(.)) %>% #' filter(first_isolate == TRUE, #' mo == as.mo("E. coli")) %>% -#' # `age_groups` is also a function of this AMR package: +#' # age_groups() is also a function in this AMR package: #' group_by(age_group = age_groups(age)) %>% #' select(age_group, #' CIP) %>% diff --git a/R/globals.R b/R/globals.R index ae241001..f615d4b5 100755 --- a/R/globals.R +++ b/R/globals.R @@ -73,5 +73,6 @@ globalVariables(c(".rowid", "value", "varname", "xvar", + "y", "year", "yvar")) diff --git a/R/is_new_episode.R b/R/is_new_episode.R index 13ec756e..1b6bfd96 100644 --- a/R/is_new_episode.R +++ b/R/is_new_episode.R @@ -33,7 +33,7 @@ #' @details #' Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least `episode_days` days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least `episode_days` days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored. #' -#' The `dplyr` package is not required for this function to work, but this function works conveniently inside `dplyr` verbs such as [filter()], [mutate()] and [summarise()]. +#' The `dplyr` package is not required for this function to work, but this function works conveniently inside `dplyr` verbs such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()]. #' @return a [logical] vector #' @export #' @inheritSection AMR Read more on our website! @@ -86,23 +86,17 @@ is_new_episode <- function(x, episode_days = 365, ...) { x <- as.double(as.Date(x, ...)) # as.Date() for POSIX classes if (length(x) == 1) { return(TRUE) - } - if (length(x) == 2 && max(x) - min(x) >= episode_days) { - return(rep(TRUE, 2)) + } else if (length(x) == 2) { + if (max(x) - min(x) >= episode_days) { + return(c(TRUE, TRUE)) + } else { + return(c(TRUE, FALSE)) + } } # I asked on StackOverflow: # https://stackoverflow.com/questions/42122245/filter-one-row-every-year exec <- function(x, episode_days) { - if (length(x) == 1) { - return(TRUE) - } else if (length(x) == 2) { - if (max(x) - min(x) >= episode_days) { - return(c(TRUE, TRUE)) - } else { - return(c(TRUE, FALSE)) - } - } indices <- integer() start <- x[1] ind <- 1 diff --git a/docs/404.html b/docs/404.html index 284968d7..97432560 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9025 + 1.4.0.9026 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 457bd022..53c1f42f 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9025 + 1.4.0.9026 diff --git a/docs/articles/index.html b/docs/articles/index.html index e61d52d7..890970c7 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9025 + 1.4.0.9026 diff --git a/docs/authors.html b/docs/authors.html index cd1a905f..374c7cf9 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9025 + 1.4.0.9026 diff --git a/docs/index.html b/docs/index.html index 8f28ce39..b19c85a3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.4.0.9025 + 1.4.0.9026 diff --git a/docs/news/index.html b/docs/news/index.html index 3a731784..3c294c93 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9025 + 1.4.0.9026 @@ -236,13 +236,13 @@ Source: NEWS.md -
-

-AMR 1.4.0.9025 Unreleased +
+

+AMR 1.4.0.9026 Unreleased

-
+

-Last updated: 23 November 2020 +Last updated: 24 November 2020

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 9be9c25c..71f68e16 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -12,7 +12,7 @@ articles: datasets: datasets.html resistance_predict: resistance_predict.html welcome_to_AMR: welcome_to_AMR.html -last_built: 2020-11-23T20:45Z +last_built: 2020-11-24T10:47Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index 38443340..4d91c9e5 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9025 + 1.4.0.9026

@@ -284,7 +284,7 @@ - + @@ -353,7 +353,7 @@ - +
x, .datax

a data.frame containing isolates.

...

parameters passed on to the first_isolate() function

parameters passed on to first_isolate() when using filter_first_isolate(), or parameters passed on to key_antibiotics() when using filter_first_weighted_isolate()

diff --git a/docs/reference/ggplot_rsi.html b/docs/reference/ggplot_rsi.html index ed656446..b48e8657 100644 --- a/docs/reference/ggplot_rsi.html +++ b/docs/reference/ggplot_rsi.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9008 + 1.4.0.9026
@@ -361,7 +361,7 @@ colours -

a named vector with colours for the bars. The names must be one or more of: S, SI, I, IR, R or be FALSE to use default [ggplot2][ggplot2::ggplot() colours.

+

a named vector with colours for the bars. The names must be one or more of: S, SI, I, IR, R or be FALSE to use default ggplot2 colours.

datalabels @@ -468,13 +468,12 @@ The lifecycle of this function is maturing< } # \donttest{ - # resistance of ciprofloxacine per age group example_isolates %>% mutate(first_isolate = first_isolate(.)) %>% filter(first_isolate == TRUE, mo == as.mo("E. coli")) %>% - # `age_groups` is also a function of this AMR package: + # age_groups() is also a function in this AMR package: group_by(age_group = age_groups(age)) %>% select(age_group, CIP) %>% diff --git a/docs/reference/index.html b/docs/reference/index.html index fdce8d7c..9dd0c294 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9025 + 1.4.0.9026
diff --git a/docs/reference/is_new_episode.html b/docs/reference/is_new_episode.html index 79494154..5032c1c8 100644 --- a/docs/reference/is_new_episode.html +++ b/docs/reference/is_new_episode.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9025 + 1.4.0.9026
@@ -274,6 +274,11 @@


The lifecycle of this function is experimental. An experimental function is in early stages of development. The unlying code might be changing frequently. Experimental functions might be removed without deprecation, so you are generally best off waiting until a function is more mature before you use it in production code. Experimental functions are only available in development versions of this AMR package and will thus not be included in releases that are submitted to CRAN, since such functions have not yet matured enough.

+

Read more on our website!

+ + + +

On our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

Examples

# `example_isolates` is a dataset available in the AMR package.
diff --git a/docs/survey.html b/docs/survey.html
index ad3eb8ce..10481d5c 100644
--- a/docs/survey.html
+++ b/docs/survey.html
@@ -81,7 +81,7 @@
       
       
         AMR (for R)
-        1.4.0.9025
+        1.4.0.9026
       
     

diff --git a/man/first_isolate.Rd b/man/first_isolate.Rd index 53eebcd6..fdd267a9 100755 --- a/man/first_isolate.Rd +++ b/man/first_isolate.Rd @@ -50,7 +50,7 @@ filter_first_weighted_isolate( ) } \arguments{ -\item{x, .data}{a \link{data.frame} containing isolates.} +\item{x}{a \link{data.frame} containing isolates.} \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} @@ -84,7 +84,7 @@ filter_first_weighted_isolate( \item{include_unknown}{logical to determine whether 'unknown' microorganisms should be included too, i.e. microbial code \code{"UNKNOWN"}, which defaults to \code{FALSE}. For WHONET users, this means that all records with organism code \code{"con"} (\emph{contamination}) will be excluded at default. Isolates with a microbial ID of \code{NA} will always be excluded as first isolate.} -\item{...}{parameters passed on to the \code{\link[=first_isolate]{first_isolate()}} function} +\item{...}{parameters passed on to \code{\link[=first_isolate]{first_isolate()}} when using \code{\link[=filter_first_isolate]{filter_first_isolate()}}, or parameters passed on to \code{\link[=key_antibiotics]{key_antibiotics()}} when using \code{\link[=filter_first_weighted_isolate]{filter_first_weighted_isolate()}}} } \value{ A \code{\link{logical}} vector diff --git a/man/ggplot_rsi.Rd b/man/ggplot_rsi.Rd index 3dc9b662..d2ad6313 100644 --- a/man/ggplot_rsi.Rd +++ b/man/ggplot_rsi.Rd @@ -99,7 +99,7 @@ labels_rsi_count( \item{nrow}{(when using \code{facet}) number of rows} -\item{colours}{a named vector with colours for the bars. The names must be one or more of: S, SI, I, IR, R or be \code{FALSE} to use default [ggplot2][\code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} colours.} +\item{colours}{a named vector with colours for the bars. The names must be one or more of: S, SI, I, IR, R or be \code{FALSE} to use default \link[ggplot2:ggplot]{ggplot2} colours.} \item{datalabels}{show datalabels using \code{\link[=labels_rsi_count]{labels_rsi_count()}}} @@ -194,13 +194,12 @@ if (require("ggplot2") & require("dplyr")) { } \donttest{ - # resistance of ciprofloxacine per age group example_isolates \%>\% mutate(first_isolate = first_isolate(.)) \%>\% filter(first_isolate == TRUE, mo == as.mo("E. coli")) \%>\% - # `age_groups` is also a function of this AMR package: + # age_groups() is also a function in this AMR package: group_by(age_group = age_groups(age)) \%>\% select(age_group, CIP) \%>\% diff --git a/man/is_new_episode.Rd b/man/is_new_episode.Rd index c0308105..fd8bf1a0 100644 --- a/man/is_new_episode.Rd +++ b/man/is_new_episode.Rd @@ -22,7 +22,7 @@ This function determines which items in a vector can be considered (the start of \details{ Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least \code{episode_days} days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least \code{episode_days} days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored. -The \code{dplyr} package is not required for this function to work, but this function works conveniently inside \code{dplyr} verbs such as \code{\link[=filter]{filter()}}, \code{\link[=mutate]{mutate()}} and \code{\link[=summarise]{summarise()}}. +The \code{dplyr} package is not required for this function to work, but this function works conveniently inside \code{dplyr} verbs such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}. } \section{Experimental lifecycle}{