From f03f71eceda4847c279ccdca7a165fe34c7fbf35 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Fri, 31 May 2019 14:40:15 +0200 Subject: [PATCH] (v0.6.1.9045) age test fix --- DESCRIPTION | 2 +- R/guess_ab_col.R | 9 ++++++++- docs/LICENSE-text.html | 2 +- docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 2 +- docs/reference/guess_ab_col.html | 18 +++++++++++++++--- docs/reference/index.html | 2 +- man/guess_ab_col.Rd | 11 ++++++++++- tests/testthat/test-age.R | 2 +- 11 files changed, 41 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c9e995b7..c43b3d4d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 0.6.1.9044 +Version: 0.6.1.9045 Date: 2019-05-31 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/R/guess_ab_col.R b/R/guess_ab_col.R index 2cddd3c5..6ce53715 100755 --- a/R/guess_ab_col.R +++ b/R/guess_ab_col.R @@ -21,10 +21,11 @@ #' Guess antibiotic column #' -#' This tries to find a column name in a data set based on information from the \code{\link{antibiotics}} data set. Also supports WHONET abbreviations. You can look for an antibiotic (trade) name or abbreviation and it will search the \code{data.frame} for any column containing a name or ATC code of that antibiotic. +#' This tries to find a column name in a data set based on information from the \code{\link{antibiotics}} data set. Also supports WHONET abbreviations. #' @param x a \code{data.frame} #' @param search_string a text to search \code{x} for #' @param verbose a logical to indicate whether additional info should be printed +#' @details You can look for an antibiotic (trade) name or abbreviation and it will search \code{x} and the \code{\link{antibiotics}} data set for any column containing a name or ATC code of that antibiotic. \strong{Longer columns names take precendence over shorter column names.} #' @importFrom dplyr %>% select filter_all any_vars #' @importFrom crayon blue #' @return A column name of \code{x}, or \code{NULL} when no result is found. @@ -52,6 +53,12 @@ #' # [1] "AMC_ED20" #' guess_ab_col(df, as.ab("augmentin")) #' # [1] "AMC_ED20" +#' +#' # Longer names take precendence: +#' df <- data.frame(AMP_ED2 = "S", +#' AMP_ED20 = "S") +#' guess_ab_col(df, "ampicillin") +#' # [1] "AMP_ED20" guess_ab_col <- function(x = NULL, search_string = NULL, verbose = FALSE) { if (is.null(x) & is.null(search_string)) { return(as.name("guess_ab_col")) diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 42c8f8ed..6199e1b3 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@ AMR (for R) - 0.6.1.9044 + 0.6.1.9045 diff --git a/docs/articles/index.html b/docs/articles/index.html index c7404fc2..ce33f5f7 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -78,7 +78,7 @@ AMR (for R) - 0.6.1.9044 + 0.6.1.9045 diff --git a/docs/authors.html b/docs/authors.html index 5221cdff..48e3be13 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -78,7 +78,7 @@ AMR (for R) - 0.6.1.9044 + 0.6.1.9045 diff --git a/docs/index.html b/docs/index.html index 03d64f74..bdbec43f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 0.6.1.9044 + 0.6.1.9045 diff --git a/docs/news/index.html b/docs/news/index.html index d50c1034..173c5438 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -78,7 +78,7 @@ AMR (for R) - 0.6.1.9044 + 0.6.1.9045 diff --git a/docs/reference/guess_ab_col.html b/docs/reference/guess_ab_col.html index c40835a8..fe134088 100644 --- a/docs/reference/guess_ab_col.html +++ b/docs/reference/guess_ab_col.html @@ -47,7 +47,7 @@ - + @@ -80,7 +80,7 @@ AMR (for R) - 0.6.1.9044 + 0.6.1.9045 @@ -244,7 +244,7 @@
-

This tries to find a column name in a data set based on information from the antibiotics data set. Also supports WHONET abbreviations. You can look for an antibiotic (trade) name or abbreviation and it will search the data.frame for any column containing a name or ATC code of that antibiotic.

+

This tries to find a column name in a data set based on information from the antibiotics data set. Also supports WHONET abbreviations.

@@ -271,6 +271,10 @@

A column name of x, or NULL when no result is found.

+

Details

+ +

You can look for an antibiotic (trade) name or abbreviation and it will search x and the antibiotics data set for any column containing a name or ATC code of that antibiotic. Longer columns names take precendence over shorter column names.

+

Read more on our website!

@@ -300,6 +304,12 @@ # [1] "AMC_ED20" guess_ab_col(df, as.ab("augmentin")) # [1] "AMC_ED20" + +# Longer names take precendence: +df <- data.frame(AMP_ED2 = "S", + AMP_ED20 = "S") +guess_ab_col(df, "ampicillin") +# [1] "AMP_ED20" # } diff --git a/man/guess_ab_col.Rd b/man/guess_ab_col.Rd index b7a1625b..ff98d607 100644 --- a/man/guess_ab_col.Rd +++ b/man/guess_ab_col.Rd @@ -17,7 +17,10 @@ guess_ab_col(x = NULL, search_string = NULL, verbose = FALSE) A column name of \code{x}, or \code{NULL} when no result is found. } \description{ -This tries to find a column name in a data set based on information from the \code{\link{antibiotics}} data set. Also supports WHONET abbreviations. You can look for an antibiotic (trade) name or abbreviation and it will search the \code{data.frame} for any column containing a name or ATC code of that antibiotic. +This tries to find a column name in a data set based on information from the \code{\link{antibiotics}} data set. Also supports WHONET abbreviations. +} +\details{ +You can look for an antibiotic (trade) name or abbreviation and it will search \code{x} and the \code{\link{antibiotics}} data set for any column containing a name or ATC code of that antibiotic. \strong{Longer columns names take precendence over shorter column names.} } \section{Read more on our website!}{ @@ -46,4 +49,10 @@ guess_ab_col(df, "J01CR02") # [1] "AMC_ED20" guess_ab_col(df, as.ab("augmentin")) # [1] "AMC_ED20" + +# Longer names take precendence: +df <- data.frame(AMP_ED2 = "S", + AMP_ED20 = "S") +guess_ab_col(df, "ampicillin") +# [1] "AMP_ED20" } diff --git a/tests/testthat/test-age.R b/tests/testthat/test-age.R index f7c64a4f..7165759c 100644 --- a/tests/testthat/test-age.R +++ b/tests/testthat/test-age.R @@ -30,7 +30,7 @@ test_that("age works", { reference = "2019-09-01", exact = TRUE), c(0.6656393, 0.4191781, 0.1698630), - tolerance = 0.000001) + tolerance = 0.001) expect_error(age(x = c("1980-01-01", "1985-01-01", "1990-01-01"), reference = c("2019-01-01", "2019-01-01")))