mirror of
https://github.com/msberends/AMR.git
synced 2024-12-24 19:26:12 +01:00
(v1.4.0.9051) ab class
This commit is contained in:
parent
afc325c314
commit
ccf13dd6c0
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 1.4.0.9050
|
||||
Version: 1.4.0.9051
|
||||
Date: 2020-12-27
|
||||
Title: Antimicrobial Resistance Analysis
|
||||
Authors@R: c(
|
||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
||||
# AMR 1.4.0.9050
|
||||
# AMR 1.4.0.9051
|
||||
## <small>Last updated: 27 December 2020</small>
|
||||
|
||||
### New
|
||||
|
@ -69,7 +69,12 @@
|
||||
#' data.frame(some_column = "some_value",
|
||||
#' J01CA01 = "S") %>% # ATC code of ampicillin
|
||||
#' select(penicillins()) # only the 'J01CA01' column will be selected
|
||||
#'
|
||||
#'
|
||||
#'
|
||||
#' # with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:
|
||||
#' # (though the row names on the first are more correct)
|
||||
#' example_isolates %>% filter_carbapenems("R", "all")
|
||||
#' example_isolates %>% filter(across(carbapenems(), ~. == "R"))
|
||||
#' }
|
||||
ab_class <- function(ab_class) {
|
||||
ab_selector(ab_class, function_name = "ab_class")
|
||||
@ -156,14 +161,19 @@ tetracyclines <- function() {
|
||||
ab_selector <- function(ab_class, function_name) {
|
||||
meet_criteria(ab_class, allow_class = "character", has_length = 1, .call_depth = 1)
|
||||
meet_criteria(function_name, allow_class = "character", has_length = 1, .call_depth = 1)
|
||||
|
||||
|
||||
for (i in seq_len(length(sys.frames()))) {
|
||||
vars_df <- sys.frames()[[i]]$x
|
||||
vars_df <- tryCatch(sys.frames()[[i]]$x, error = function(e) NULL)
|
||||
if (!is.null(vars_df) && is.data.frame(vars_df)) {
|
||||
# when using e.g. example_isolates[, carbapenems()] or example_isolates %>% select(carbapenems())
|
||||
break
|
||||
} else if (!is.null(vars_df) && is.list(vars_df)) {
|
||||
# when using e.g. example_isolates %>% filter(across(carbapenems(), ~. == "R"))
|
||||
vars_df <- as.data.frame(vars_df, stringsAsFactors = FALSE)
|
||||
break
|
||||
}
|
||||
}
|
||||
stop_ifnot(is.data.frame(vars_df), "the ", function_name, "() function must be used inside dplyr verbs or a data.frame call.")
|
||||
stop_ifnot(is.data.frame(vars_df), "this function must be used inside dplyr selection verbs or within a data.frame call.", call = -2)
|
||||
ab_in_data <- get_column_abx(vars_df, info = FALSE)
|
||||
|
||||
if (length(ab_in_data) == 0) {
|
||||
@ -184,15 +194,18 @@ ab_selector <- function(ab_class, function_name) {
|
||||
}
|
||||
# get the columns with a group names in the chosen ab class
|
||||
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
|
||||
if (length(agents) == 0) {
|
||||
message_("No antimicrobial agents of class ", ab_group, " found", examples, ".")
|
||||
} else {
|
||||
message_("Selecting ", ab_group, ": ",
|
||||
paste(paste0("'", font_bold(agents, collapse = NULL),
|
||||
"' (", ab_name(names(agents), tolower = TRUE, language = NULL), ")"),
|
||||
collapse = ", "),
|
||||
as_note = FALSE,
|
||||
extra_indent = nchar(paste0("Selecting ", ab_group, ": ")))
|
||||
}
|
||||
if (message_not_thrown_before(function_name)) {
|
||||
if (length(agents) == 0) {
|
||||
message_("No antimicrobial agents of class ", ab_group, " found", examples, ".")
|
||||
} else {
|
||||
message_("Selecting ", ab_group, ": ",
|
||||
paste(paste0("'", font_bold(agents, collapse = NULL),
|
||||
"' (", ab_name(names(agents), tolower = TRUE, language = NULL), ")"),
|
||||
collapse = ", "),
|
||||
as_note = FALSE,
|
||||
extra_indent = nchar(paste0("Selecting ", ab_group, ": ")))
|
||||
}
|
||||
remember_thrown_message(function_name)
|
||||
}
|
||||
unname(agents)
|
||||
}
|
||||
|
@ -71,6 +71,7 @@
|
||||
#' filter_fluoroquinolones("R", "all")
|
||||
#'
|
||||
#' # with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:
|
||||
#' # (though the row names on the first are more correct)
|
||||
#' example_isolates %>% filter_carbapenems("R", "all")
|
||||
#' example_isolates %>% filter(across(carbapenems(), ~. == "R"))
|
||||
#' }
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<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.4.0.9050</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9051</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,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="Latest development version">1.4.0.9050</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9051</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,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="Latest development version">1.4.0.9050</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9051</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,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="Latest development version">1.4.0.9050</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9051</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -43,7 +43,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="Latest development version">1.4.0.9050</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9051</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,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="Latest development version">1.4.0.9050</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9051</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -236,9 +236,9 @@
|
||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="amr-1409050" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.4.0.9050">
|
||||
<a href="#amr-1409050" class="anchor"></a>AMR 1.4.0.9050<small> Unreleased </small>
|
||||
<div id="amr-1409051" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.4.0.9051">
|
||||
<a href="#amr-1409051" class="anchor"></a>AMR 1.4.0.9051<small> Unreleased </small>
|
||||
</h1>
|
||||
<div id="last-updated-27-december-2020" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
|
@ -12,7 +12,7 @@ articles:
|
||||
datasets: datasets.html
|
||||
resistance_predict: resistance_predict.html
|
||||
welcome_to_AMR: welcome_to_AMR.html
|
||||
last_built: 2020-12-27T19:32Z
|
||||
last_built: 2020-12-27T22:17Z
|
||||
urls:
|
||||
reference: https://msberends.github.io/AMR//reference
|
||||
article: https://msberends.github.io/AMR//articles
|
||||
|
@ -82,7 +82,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="Latest development version">1.4.0.9050</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9051</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -331,7 +331,12 @@
|
||||
<span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span><span class='op'>(</span>some_column <span class='op'>=</span> <span class='st'>"some_value"</span>,
|
||||
J01CA01 <span class='op'>=</span> <span class='st'>"S"</span><span class='op'>)</span> <span class='op'>%>%</span> <span class='co'># ATC code of ampicillin</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='fu'>penicillins</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span> <span class='co'># only the 'J01CA01' column will be selected</span>
|
||||
|
||||
|
||||
|
||||
<span class='co'># with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:</span>
|
||||
<span class='co'># (though the row names on the first are more correct)</span>
|
||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span> <span class='fu'><a href='filter_ab_class.html'>filter_carbapenems</a></span><span class='op'>(</span><span class='st'>"R"</span>, <span class='st'>"all"</span><span class='op'>)</span>
|
||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span><span class='op'>(</span><span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span><span class='op'>(</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span>, <span class='op'>~</span><span class='va'>.</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span><span class='op'>)</span>
|
||||
<span class='op'>}</span>
|
||||
</pre>
|
||||
</div>
|
||||
|
@ -82,7 +82,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="Latest development version">1.4.0.9046</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9051</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -344,6 +344,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
|
||||
<span class='fu'>filter_fluoroquinolones</span><span class='op'>(</span><span class='st'>"R"</span>, <span class='st'>"all"</span><span class='op'>)</span>
|
||||
|
||||
<span class='co'># with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:</span>
|
||||
<span class='co'># (though the row names on the first are more correct)</span>
|
||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span> <span class='fu'>filter_carbapenems</span><span class='op'>(</span><span class='st'>"R"</span>, <span class='st'>"all"</span><span class='op'>)</span>
|
||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span><span class='op'>(</span><span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span><span class='op'>(</span><span class='fu'><a href='antibiotic_class_selectors.html'>carbapenems</a></span><span class='op'>(</span><span class='op'>)</span>, <span class='op'>~</span><span class='va'>.</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span><span class='op'>)</span>
|
||||
<span class='op'>}</span>
|
||||
|
@ -81,7 +81,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="Latest development version">1.4.0.9050</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9051</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,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="Latest development version">1.4.0.9050</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9051</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -100,7 +100,12 @@ if (require("dplyr")) {
|
||||
data.frame(some_column = "some_value",
|
||||
J01CA01 = "S") \%>\% # ATC code of ampicillin
|
||||
select(penicillins()) # only the 'J01CA01' column will be selected
|
||||
|
||||
|
||||
|
||||
# with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:
|
||||
# (though the row names on the first are more correct)
|
||||
example_isolates \%>\% filter_carbapenems("R", "all")
|
||||
example_isolates \%>\% filter(across(carbapenems(), ~. == "R"))
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
|
@ -105,6 +105,7 @@ if (require("dplyr")) {
|
||||
filter_fluoroquinolones("R", "all")
|
||||
|
||||
# with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:
|
||||
# (though the row names on the first are more correct)
|
||||
example_isolates \%>\% filter_carbapenems("R", "all")
|
||||
example_isolates \%>\% filter(across(carbapenems(), ~. == "R"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user