mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 08:06:12 +01:00
(v1.6.0.9003) like() fix
This commit is contained in:
parent
d277d58475
commit
00d3e437a8
8
.github/workflows/check.yaml
vendored
8
.github/workflows/check.yaml
vendored
@ -65,10 +65,10 @@ jobs:
|
|||||||
- {os: ubuntu-20.04, r: '3.6', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
- {os: ubuntu-20.04, r: '3.6', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||||
- {os: ubuntu-20.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
- {os: ubuntu-20.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||||
- {os: ubuntu-20.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
- {os: ubuntu-20.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||||
- {os: ubuntu-20.04, r: '3.3', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
- {os: ubuntu-20.04, r: '3.3', allowfail: false rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||||
# - {os: ubuntu-20.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
# - {os: ubuntu-20.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||||
# - {os: ubuntu-20.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
# - {os: ubuntu-20.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||||
- {os: ubuntu-20.04, r: '3.0', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
- {os: ubuntu-20.04, r: '3.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||||
|
|
||||||
- {os: ubuntu-16.04, r: 'devel', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: 'devel', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
- {os: ubuntu-16.04, r: 'release', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: 'release', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
@ -77,10 +77,10 @@ jobs:
|
|||||||
- {os: ubuntu-16.04, r: '3.6', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: '3.6', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
- {os: ubuntu-16.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
- {os: ubuntu-16.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
- {os: ubuntu-16.04, r: '3.3', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: '3.3', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
# - {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
# - {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
# - {os: ubuntu-16.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
# - {os: ubuntu-16.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
- {os: ubuntu-16.04, r: '3.0', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: '3.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
|
|
||||||
env:
|
env:
|
||||||
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 1.6.0.9002
|
Version: 1.6.0.9003
|
||||||
Date: 2021-04-12
|
Date: 2021-04-16
|
||||||
Title: Antimicrobial Resistance Data Analysis
|
Title: Antimicrobial Resistance Data Analysis
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person(role = c("aut", "cre"),
|
person(role = c("aut", "cre"),
|
||||||
|
5
NEWS.md
5
NEWS.md
@ -1,5 +1,5 @@
|
|||||||
# AMR 1.6.0.9002
|
# AMR 1.6.0.9003
|
||||||
## <small>Last updated: 12 April 2021</small>
|
## <small>Last updated: 16 April 2021</small>
|
||||||
|
|
||||||
### New
|
### New
|
||||||
* Function `custom_eucast_rules()` that brings support for custom AMR rules in `eucast_rules()`
|
* Function `custom_eucast_rules()` that brings support for custom AMR rules in `eucast_rules()`
|
||||||
@ -13,6 +13,7 @@
|
|||||||
* Fix for minor translation errors
|
* Fix for minor translation errors
|
||||||
* Printing of microbial codes in a `data.frame` or `tibble` now gives a warning if the data contains old microbial codes (from a previous AMR package version)
|
* Printing of microbial codes in a `data.frame` or `tibble` now gives a warning if the data contains old microbial codes (from a previous AMR package version)
|
||||||
* `first_isolate()` can now take a vector of values for `col_keyantibiotics` and can have an episode length of `Inf`
|
* `first_isolate()` can now take a vector of values for `col_keyantibiotics` and can have an episode length of `Inf`
|
||||||
|
* `like()` (and `%like%`) now checks if `pattern` is a *valid* regular expression
|
||||||
* Fixed an installation error on R-3.0
|
* Fixed an installation error on R-3.0
|
||||||
|
|
||||||
# AMR 1.6.0
|
# AMR 1.6.0
|
||||||
|
@ -211,10 +211,20 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
|||||||
found
|
found
|
||||||
}
|
}
|
||||||
|
|
||||||
is_possibly_regex <- function(x) {
|
is_valid_regex <- function(x) {
|
||||||
tryCatch(vapply(FUN.VALUE = character(1), strsplit(x, ""),
|
regex_at_all <- tryCatch(vapply(FUN.VALUE = logical(1),
|
||||||
function(y) any(y %in% c("$", "(", ")", "*", "+", "-", ".", "?", "[", "]", "^", "{", "|", "}", "\\"), na.rm = TRUE)),
|
X = strsplit(x, ""),
|
||||||
|
FUN = function(y) any(y %in% c("$", "(", ")", "*", "+", "-",
|
||||||
|
".", "?", "[", "]", "^", "{",
|
||||||
|
"|", "}", "\\"),
|
||||||
|
na.rm = TRUE)),
|
||||||
error = function(e) rep(TRUE, length(x)))
|
error = function(e) rep(TRUE, length(x)))
|
||||||
|
regex_valid <- vapply(FUN.VALUE = logical(1),
|
||||||
|
X = c("[.", "."),
|
||||||
|
FUN = function(y) !"try-error" %in% class(try(grepl(y, ""),
|
||||||
|
silent = TRUE)),
|
||||||
|
USE.NAMES = FALSE)
|
||||||
|
regex_at_all & regex_valid
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_ifnot_installed <- function(package) {
|
stop_ifnot_installed <- function(package) {
|
||||||
|
17
R/like.R
17
R/like.R
@ -28,21 +28,21 @@
|
|||||||
#' Convenient wrapper around [grepl()] to match a pattern: `x %like% pattern`. It always returns a [`logical`] vector and is always case-insensitive (use `x %like_case% pattern` for case-sensitive matching). Also, `pattern` can be as long as `x` to compare items of each index in both vectors, or they both can have the same length to iterate over all cases.
|
#' Convenient wrapper around [grepl()] to match a pattern: `x %like% pattern`. It always returns a [`logical`] vector and is always case-insensitive (use `x %like_case% pattern` for case-sensitive matching). Also, `pattern` can be as long as `x` to compare items of each index in both vectors, or they both can have the same length to iterate over all cases.
|
||||||
#' @inheritSection lifecycle Stable Lifecycle
|
#' @inheritSection lifecycle Stable Lifecycle
|
||||||
#' @param x a character vector where matches are sought, or an object which can be coerced by [as.character()] to a character vector.
|
#' @param x a character vector where matches are sought, or an object which can be coerced by [as.character()] to a character vector.
|
||||||
#' @param pattern a character string containing a regular expression (or [character] string for `fixed = TRUE`) to be matched in the given character vector. Coerced by [as.character()] to a character string if possible. If a [character] vector of length 2 or more is supplied, the first element is used with a warning.
|
#' @param pattern a character vector containing regular expressions (or a [character] string for `fixed = TRUE`) to be matched in the given character vector. Coerced by [as.character()] to a character string if possible.
|
||||||
#' @param ignore.case if `FALSE`, the pattern matching is *case sensitive* and if `TRUE`, case is ignored during matching.
|
#' @param ignore.case if `FALSE`, the pattern matching is *case sensitive* and if `TRUE`, case is ignored during matching.
|
||||||
#' @return A [logical] vector
|
#' @return A [logical] vector
|
||||||
#' @name like
|
#' @name like
|
||||||
#' @rdname like
|
#' @rdname like
|
||||||
#' @export
|
#' @export
|
||||||
#' @details
|
#' @details
|
||||||
#' The `%like%` function:
|
#' This `%like%` function:
|
||||||
#' * Is case-insensitive (use `%like_case%` for case-sensitive matching)
|
#' * Is case-insensitive (use `%like_case%` for case-sensitive matching)
|
||||||
#' * Supports multiple patterns
|
#' * Supports multiple patterns
|
||||||
#' * Checks if `pattern` is a regular expression and sets `fixed = TRUE` if not, to greatly improve speed
|
#' * Checks if `pattern` is a valid regular expression and sets `fixed = TRUE` if not, to greatly improve speed (vectorised over `pattern`)
|
||||||
#' * Always uses compatibility with Perl unless `fixed = TRUE`, to greatly improve speed
|
#' * Always uses compatibility with Perl unless `fixed = TRUE`, to greatly improve speed
|
||||||
#'
|
#'
|
||||||
#' Using RStudio? The text `%like%` can also be directly inserted in your code from the Addins menu and can have its own Keyboard Shortcut like `Ctrl+Shift+L` or `Cmd+Shift+L` (see `Tools` > `Modify Keyboard Shortcuts...`).
|
#' Using RStudio? The text `%like%` can also be directly inserted in your code from the Addins menu and can have its own Keyboard Shortcut like `Ctrl+Shift+L` or `Cmd+Shift+L` (see `Tools` > `Modify Keyboard Shortcuts...`).
|
||||||
#' @source Idea from the [`like` function from the `data.table` package](https://github.com/Rdatatable/data.table/blob/ec1259af1bf13fc0c96a1d3f9e84d55d8106a9a4/R/like.R)
|
#' @source Idea from the [`like` function from the `data.table` package](https://github.com/Rdatatable/data.table/blob/ec1259af1bf13fc0c96a1d3f9e84d55d8106a9a4/R/like.R), although altered as explained in *Details*.
|
||||||
#' @seealso [grepl()]
|
#' @seealso [grepl()]
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
#' @examples
|
#' @examples
|
||||||
@ -80,8 +80,9 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
|||||||
return(rep(FALSE, length(x)))
|
return(rep(FALSE, length(x)))
|
||||||
}
|
}
|
||||||
|
|
||||||
# set to fixed if no regex found
|
# set to fixed if no valid regex (vectorised)
|
||||||
fixed <- !any(is_possibly_regex(pattern))
|
fixed <- !is_valid_regex(pattern)
|
||||||
|
|
||||||
if (ignore.case == TRUE) {
|
if (ignore.case == TRUE) {
|
||||||
# set here, otherwise if fixed = TRUE, this warning will be thrown: argument `ignore.case = TRUE` will be ignored
|
# set here, otherwise if fixed = TRUE, this warning will be thrown: argument `ignore.case = TRUE` will be ignored
|
||||||
x <- tolower(x)
|
x <- tolower(x)
|
||||||
@ -105,7 +106,9 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
|||||||
mapply(FUN = grepl,
|
mapply(FUN = grepl,
|
||||||
x = x,
|
x = x,
|
||||||
pattern = pattern,
|
pattern = pattern,
|
||||||
MoreArgs = list(ignore.case = FALSE, fixed = fixed, perl = !fixed),
|
fixed = fixed,
|
||||||
|
perl = !fixed,
|
||||||
|
MoreArgs = list(ignore.case = FALSE),
|
||||||
SIMPLIFY = FALSE,
|
SIMPLIFY = FALSE,
|
||||||
USE.NAMES = FALSE)
|
USE.NAMES = FALSE)
|
||||||
)
|
)
|
||||||
|
BIN
R/sysdata.rda
BIN
R/sysdata.rda
Binary file not shown.
Binary file not shown.
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9002</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9002</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9002</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9002</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -236,13 +236,13 @@
|
|||||||
<small class="dont-index">Source: <a href='https://github.com/msberends/AMR/blob/master/inst/CITATION'><code>inst/CITATION</code></a></small>
|
<small class="dont-index">Source: <a href='https://github.com/msberends/AMR/blob/master/inst/CITATION'><code>inst/CITATION</code></a></small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>Berends MS, Luz CF et al. (2019). AMR - An R Package for Working with Antimicrobial Resistance Data. bioRxiv, https://doi.org/10.1101/810622</p>
|
<p>Berends MS, Luz CF et al. (2021). AMR - An R Package for Working with Antimicrobial Resistance Data. bioRxiv, https://doi.org/10.1101/810622</p>
|
||||||
<pre>@Article{,
|
<pre>@Article{,
|
||||||
title = {AMR - An R Package for Working with Antimicrobial Resistance Data},
|
title = {AMR - An R Package for Working with Antimicrobial Resistance Data},
|
||||||
author = {M S Berends and C F Luz and A W Friedrich and B N M Sinha and C J Albers and C Glasner},
|
author = {M S Berends and C F Luz and A W Friedrich and B N M Sinha and C J Albers and C Glasner},
|
||||||
journal = {bioRxiv},
|
journal = {bioRxiv},
|
||||||
publisher = {Cold Spring Harbor Laboratory},
|
publisher = {Cold Spring Harbor Laboratory},
|
||||||
year = {2019},
|
year = {2021},
|
||||||
url = {https://doi.org/10.1101/810622},
|
url = {https://doi.org/10.1101/810622},
|
||||||
}</pre>
|
}</pre>
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9002</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9002</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -236,13 +236,13 @@
|
|||||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="amr-1609002" class="section level1">
|
<div id="amr-1609003" class="section level1">
|
||||||
<h1 class="page-header" data-toc-text="1.6.0.9002">
|
<h1 class="page-header" data-toc-text="1.6.0.9003">
|
||||||
<a href="#amr-1609002" class="anchor"></a>AMR 1.6.0.9002<small> Unreleased </small>
|
<a href="#amr-1609003" class="anchor"></a>AMR 1.6.0.9003<small> Unreleased </small>
|
||||||
</h1>
|
</h1>
|
||||||
<div id="last-updated-12-april-2021" class="section level2">
|
<div id="last-updated-16-april-2021" class="section level2">
|
||||||
<h2 class="hasAnchor">
|
<h2 class="hasAnchor">
|
||||||
<a href="#last-updated-12-april-2021" class="anchor"></a><small>Last updated: 12 April 2021</small>
|
<a href="#last-updated-16-april-2021" class="anchor"></a><small>Last updated: 16 April 2021</small>
|
||||||
</h2>
|
</h2>
|
||||||
<div id="new" class="section level3">
|
<div id="new" class="section level3">
|
||||||
<h3 class="hasAnchor">
|
<h3 class="hasAnchor">
|
||||||
@ -270,6 +270,8 @@
|
|||||||
<li>
|
<li>
|
||||||
<code><a href="../reference/first_isolate.html">first_isolate()</a></code> can now take a vector of values for <code>col_keyantibiotics</code> and can have an episode length of <code>Inf</code>
|
<code><a href="../reference/first_isolate.html">first_isolate()</a></code> can now take a vector of values for <code>col_keyantibiotics</code> and can have an episode length of <code>Inf</code>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<code><a href="../reference/like.html">like()</a></code> (and <code><a href="../reference/like.html">%like%</a></code>) now checks if <code>pattern</code> is a <em>valid</em> regular expression</li>
|
||||||
<li>Fixed an installation error on R-3.0</li>
|
<li>Fixed an installation error on R-3.0</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,7 @@ articles:
|
|||||||
datasets: datasets.html
|
datasets: datasets.html
|
||||||
resistance_predict: resistance_predict.html
|
resistance_predict: resistance_predict.html
|
||||||
welcome_to_AMR: welcome_to_AMR.html
|
welcome_to_AMR: welcome_to_AMR.html
|
||||||
last_built: 2021-04-12T12:24Z
|
last_built: 2021-04-16T09:40Z
|
||||||
urls:
|
urls:
|
||||||
reference: https://msberends.github.io/AMR//reference
|
reference: https://msberends.github.io/AMR//reference
|
||||||
article: https://msberends.github.io/AMR//articles
|
article: https://msberends.github.io/AMR//articles
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9001</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9001</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9002</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9001</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -257,7 +257,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>pattern</th>
|
<th>pattern</th>
|
||||||
<td><p>a character string containing a regular expression (or <a href='https://rdrr.io/r/base/character.html'>character</a> string for <code>fixed = TRUE</code>) to be matched in the given character vector. Coerced by <code><a href='https://rdrr.io/r/base/character.html'>as.character()</a></code> to a character string if possible. If a <a href='https://rdrr.io/r/base/character.html'>character</a> vector of length 2 or more is supplied, the first element is used with a warning.</p></td>
|
<td><p>a character vector containing regular expressions (or a <a href='https://rdrr.io/r/base/character.html'>character</a> string for <code>fixed = TRUE</code>) to be matched in the given character vector. Coerced by <code><a href='https://rdrr.io/r/base/character.html'>as.character()</a></code> to a character string if possible.</p></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>ignore.case</th>
|
<th>ignore.case</th>
|
||||||
@ -267,16 +267,16 @@
|
|||||||
|
|
||||||
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
|
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
|
||||||
|
|
||||||
<p>Idea from the <a href='https://github.com/Rdatatable/data.table/blob/ec1259af1bf13fc0c96a1d3f9e84d55d8106a9a4/R/like.R'><code>like</code> function from the <code>data.table</code> package</a></p>
|
<p>Idea from the <a href='https://github.com/Rdatatable/data.table/blob/ec1259af1bf13fc0c96a1d3f9e84d55d8106a9a4/R/like.R'><code>like</code> function from the <code>data.table</code> package</a>, although altered as explained in <em>Details</em>.</p>
|
||||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||||
|
|
||||||
<p>A <a href='https://rdrr.io/r/base/logical.html'>logical</a> vector</p>
|
<p>A <a href='https://rdrr.io/r/base/logical.html'>logical</a> vector</p>
|
||||||
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
|
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
|
||||||
|
|
||||||
<p>The <code>%like%</code> function:</p><ul>
|
<p>This <code>%like%</code> function:</p><ul>
|
||||||
<li><p>Is case-insensitive (use <code>%like_case%</code> for case-sensitive matching)</p></li>
|
<li><p>Is case-insensitive (use <code>%like_case%</code> for case-sensitive matching)</p></li>
|
||||||
<li><p>Supports multiple patterns</p></li>
|
<li><p>Supports multiple patterns</p></li>
|
||||||
<li><p>Checks if <code>pattern</code> is a regular expression and sets <code>fixed = TRUE</code> if not, to greatly improve speed</p></li>
|
<li><p>Checks if <code>pattern</code> is a valid regular expression and sets <code>fixed = TRUE</code> if not, to greatly improve speed (vectorised over <code>pattern</code>)</p></li>
|
||||||
<li><p>Always uses compatibility with Perl unless <code>fixed = TRUE</code>, to greatly improve speed</p></li>
|
<li><p>Always uses compatibility with Perl unless <code>fixed = TRUE</code>, to greatly improve speed</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9002</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9003</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@ citEntry(
|
|||||||
author = "M S Berends and C F Luz and A W Friedrich and B N M Sinha and C J Albers and C Glasner",
|
author = "M S Berends and C F Luz and A W Friedrich and B N M Sinha and C J Albers and C Glasner",
|
||||||
journal = "bioRxiv",
|
journal = "bioRxiv",
|
||||||
publisher = "Cold Spring Harbor Laboratory",
|
publisher = "Cold Spring Harbor Laboratory",
|
||||||
year = 2019,
|
year = 2021,
|
||||||
url = "https://doi.org/10.1101/810622",
|
url = "https://doi.org/10.1101/810622",
|
||||||
textVersion = "Berends MS, Luz CF et al. (2019). AMR - An R Package for Working with Antimicrobial Resistance Data. bioRxiv, https://doi.org/10.1101/810622"
|
textVersion = "Berends MS, Luz CF et al. (2021). AMR - An R Package for Working with Antimicrobial Resistance Data. bioRxiv, https://doi.org/10.1101/810622"
|
||||||
)
|
)
|
||||||
|
|
||||||
citFooter("The mentioned article is a preprinted version of a manuscript we sent to a journal. Many thanks for using our open-source method to work with microbial and antimicrobial data!")
|
citFooter("This preprint was accepted for publication in the Journal of Statistical Software, but we are awaiting the actual publication. Many thanks for using our open-source method to work with microbial and antimicrobial data!")
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
\alias{\%like_case\%}
|
\alias{\%like_case\%}
|
||||||
\title{Vectorised Pattern Matching with Keyboard Shortcut}
|
\title{Vectorised Pattern Matching with Keyboard Shortcut}
|
||||||
\source{
|
\source{
|
||||||
Idea from the \href{https://github.com/Rdatatable/data.table/blob/ec1259af1bf13fc0c96a1d3f9e84d55d8106a9a4/R/like.R}{\code{like} function from the \code{data.table} package}
|
Idea from the \href{https://github.com/Rdatatable/data.table/blob/ec1259af1bf13fc0c96a1d3f9e84d55d8106a9a4/R/like.R}{\code{like} function from the \code{data.table} package}, although altered as explained in \emph{Details}.
|
||||||
}
|
}
|
||||||
\usage{
|
\usage{
|
||||||
like(x, pattern, ignore.case = TRUE)
|
like(x, pattern, ignore.case = TRUE)
|
||||||
@ -18,7 +18,7 @@ x \%like_case\% pattern
|
|||||||
\arguments{
|
\arguments{
|
||||||
\item{x}{a character vector where matches are sought, or an object which can be coerced by \code{\link[=as.character]{as.character()}} to a character vector.}
|
\item{x}{a character vector where matches are sought, or an object which can be coerced by \code{\link[=as.character]{as.character()}} to a character vector.}
|
||||||
|
|
||||||
\item{pattern}{a character string containing a regular expression (or \link{character} string for \code{fixed = TRUE}) to be matched in the given character vector. Coerced by \code{\link[=as.character]{as.character()}} to a character string if possible. If a \link{character} vector of length 2 or more is supplied, the first element is used with a warning.}
|
\item{pattern}{a character vector containing regular expressions (or a \link{character} string for \code{fixed = TRUE}) to be matched in the given character vector. Coerced by \code{\link[=as.character]{as.character()}} to a character string if possible.}
|
||||||
|
|
||||||
\item{ignore.case}{if \code{FALSE}, the pattern matching is \emph{case sensitive} and if \code{TRUE}, case is ignored during matching.}
|
\item{ignore.case}{if \code{FALSE}, the pattern matching is \emph{case sensitive} and if \code{TRUE}, case is ignored during matching.}
|
||||||
}
|
}
|
||||||
@ -29,11 +29,11 @@ A \link{logical} vector
|
|||||||
Convenient wrapper around \code{\link[=grepl]{grepl()}} to match a pattern: \code{x \%like\% pattern}. It always returns a \code{\link{logical}} vector and is always case-insensitive (use \code{x \%like_case\% pattern} for case-sensitive matching). Also, \code{pattern} can be as long as \code{x} to compare items of each index in both vectors, or they both can have the same length to iterate over all cases.
|
Convenient wrapper around \code{\link[=grepl]{grepl()}} to match a pattern: \code{x \%like\% pattern}. It always returns a \code{\link{logical}} vector and is always case-insensitive (use \code{x \%like_case\% pattern} for case-sensitive matching). Also, \code{pattern} can be as long as \code{x} to compare items of each index in both vectors, or they both can have the same length to iterate over all cases.
|
||||||
}
|
}
|
||||||
\details{
|
\details{
|
||||||
The \verb{\%like\%} function:
|
This \verb{\%like\%} function:
|
||||||
\itemize{
|
\itemize{
|
||||||
\item Is case-insensitive (use \verb{\%like_case\%} for case-sensitive matching)
|
\item Is case-insensitive (use \verb{\%like_case\%} for case-sensitive matching)
|
||||||
\item Supports multiple patterns
|
\item Supports multiple patterns
|
||||||
\item Checks if \code{pattern} is a regular expression and sets \code{fixed = TRUE} if not, to greatly improve speed
|
\item Checks if \code{pattern} is a valid regular expression and sets \code{fixed = TRUE} if not, to greatly improve speed (vectorised over \code{pattern})
|
||||||
\item Always uses compatibility with Perl unless \code{fixed = TRUE}, to greatly improve speed
|
\item Always uses compatibility with Perl unless \code{fixed = TRUE}, to greatly improve speed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ test_that("EUCAST rules work", {
|
|||||||
"reference.version",
|
"reference.version",
|
||||||
"note"))
|
"note"))
|
||||||
MOs_mentioned <- unique(eucast_rules_file$this_value)
|
MOs_mentioned <- unique(eucast_rules_file$this_value)
|
||||||
MOs_mentioned <- sort(trimws(unlist(strsplit(MOs_mentioned[!is_possibly_regex(MOs_mentioned)], ",", fixed = TRUE))))
|
MOs_mentioned <- sort(trimws(unlist(strsplit(MOs_mentioned[!is_valid_regex(MOs_mentioned)], ",", fixed = TRUE))))
|
||||||
MOs_test <- suppressWarnings(suppressMessages(mo_name(MOs_mentioned)))
|
MOs_test <- suppressWarnings(suppressMessages(mo_name(MOs_mentioned)))
|
||||||
expect_length(MOs_mentioned[MOs_test != MOs_mentioned], 0)
|
expect_length(MOs_mentioned[MOs_test != MOs_mentioned], 0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user