1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-25 19:26:13 +01:00

(v0.6.1.9045) age test fix

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-05-31 14:40:15 +02:00
parent 493ae2ba0c
commit f03f71eced
11 changed files with 41 additions and 13 deletions

View File

@ -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(

View File

@ -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"))

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9044</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9045</span>
</span>
</div>

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9044</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9045</span>
</span>
</div>

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9044</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9045</span>
</span>
</div>

View File

@ -42,7 +42,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9044</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9045</span>
</span>
</div>

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9044</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9045</span>
</span>
</div>

View File

@ -47,7 +47,7 @@
<script src="../extra.js"></script>
<meta property="og:title" content="Guess antibiotic column — guess_ab_col" />
<meta property="og:description" content="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." />
<meta property="og:description" content="This tries to find a column name in a data set based on information from the antibiotics data set. Also supports WHONET abbreviations." />
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" />
<meta name="twitter:card" content="summary" />
@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9044</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9045</span>
</span>
</div>
@ -244,7 +244,7 @@
<div class="ref-description">
<p>This tries to find a column name in a data set based on information from the <code><a href='antibiotics.html'>antibiotics</a></code> data set. Also supports WHONET abbreviations. You can look for an antibiotic (trade) name or abbreviation and it will search the <code>data.frame</code> for any column containing a name or ATC code of that antibiotic.</p>
<p>This tries to find a column name in a data set based on information from the <code><a href='antibiotics.html'>antibiotics</a></code> data set. Also supports WHONET abbreviations.</p>
</div>
@ -271,6 +271,10 @@
<p>A column name of <code>x</code>, or <code>NULL</code> when no result is found.</p>
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p>You can look for an antibiotic (trade) name or abbreviation and it will search <code>x</code> and the <code><a href='antibiotics.html'>antibiotics</a></code> data set for any column containing a name or ATC code of that antibiotic. <strong>Longer columns names take precendence over shorter column names.</strong></p>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
@ -300,6 +304,12 @@
<span class='co'># [1] "AMC_ED20"</span>
<span class='fu'>guess_ab_col</span>(<span class='no'>df</span>, <span class='fu'><a href='as.ab.html'>as.ab</a></span>(<span class='st'>"augmentin"</span>))
<span class='co'># [1] "AMC_ED20"</span>
<span class='co'># Longer names take precendence:</span>
<span class='no'>df</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></span>(<span class='kw'>AMP_ED2</span> <span class='kw'>=</span> <span class='st'>"S"</span>,
<span class='kw'>AMP_ED20</span> <span class='kw'>=</span> <span class='st'>"S"</span>)
<span class='fu'>guess_ab_col</span>(<span class='no'>df</span>, <span class='st'>"ampicillin"</span>)
<span class='co'># [1] "AMP_ED20"</span>
<span class='co'># }</span></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
@ -309,6 +319,8 @@
<li><a href="#value">Value</a></li>
<li><a href="#details">Details</a></li>
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
<li><a href="#examples">Examples</a></li>

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9044</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9045</span>
</span>
</div>

View File

@ -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"
}

View File

@ -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")))