(v1.3.0.9032) support skimr

v1.8.2
parent 22f6ceb3e4
commit 519aada54f

@ -63,5 +63,5 @@ jobs:
shell: Rscript {0}
- name: Test coverage
run: covr::codecov(line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/resistance_predict.R", "R/aa_helper_functions_dplyr.R"), quiet = FALSE)
run: covr::codecov(line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/resistance_predict.R", "R/aa_helper_pm_functions.R", "R/zzz.R"), quiet = FALSE)
shell: Rscript {0}

@ -1,6 +1,6 @@
Package: AMR
Version: 1.3.0.9031
Date: 2020-09-26
Version: 1.3.0.9032
Date: 2020-09-28
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(role = c("aut", "cre"),
@ -51,6 +51,7 @@ Suggests:
rmarkdown,
rstudioapi,
rvest,
skimr,
testthat,
tidyr,
xml2

@ -1,5 +1,5 @@
# AMR 1.3.0.9031
## <small>Last updated: 26 September 2020</small>
# AMR 1.3.0.9032
## <small>Last updated: 28 September 2020</small>
Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly!
@ -18,6 +18,7 @@ Note: some changes in this version were suggested by anonymous reviewers from th
#> [1] "Enterococcus casseliflavus" "Enterococcus gallinarum"
```
* Support for veterinary ATC codes
* Support for skimming classes `<rsi>`, `<mic>`, `<disk>` and `<mo>` with the `skimr` package
### Changed
* Although advertised that this package should work under R 3.0.0, we still had a dependency on R 3.6.0. This is fixed, meaning that our package should now work under R 3.0.0.

@ -186,3 +186,17 @@ unique.disk <- function(x, incomparables = FALSE, ...) {
attributes(y) <- attributes(x)
y
}
# will be exported using s3_register() in R/zzz.R
get_skimmers.disk <- function(column) {
sfl <- import_fn("sfl", "skimr", error_on_fail = FALSE)
inline_hist <- import_fn("inline_hist", "skimr", error_on_fail = FALSE)
sfl(
skim_type = "disk",
smallest = ~min(as.double(.), na.rm = TRUE),
largest = ~max(as.double(.), na.rm = TRUE),
median = ~stats::median(as.double(.), na.rm = TRUE),
n_unique = n_unique,
hist = ~inline_hist(stats::na.omit(as.double(.)))
)
}

@ -296,3 +296,17 @@ unique.mic <- function(x, incomparables = FALSE, ...) {
attributes(y) <- attributes(x)
y
}
# will be exported using s3_register() in R/zzz.R
get_skimmers.mic <- function(column) {
sfl <- import_fn("sfl", "skimr", error_on_fail = FALSE)
inline_hist <- import_fn("inline_hist", "skimr", error_on_fail = FALSE)
sfl(
skim_type = "mic",
min = ~as.character(sort(na.omit(.))[1]),
max = ~as.character(sort(stats::na.omit(.))[length(stats::na.omit(.))]),
median = ~as.character(stats::na.omit(.)[as.double(stats::na.omit(.)) == median(as.double(stats::na.omit(.)))])[1],
n_unique = n_unique,
hist_log2 = ~inline_hist(log2(as.double(stats::na.omit(.))))
)
}

@ -1637,11 +1637,24 @@ freq.mo <- function(x, ...) {
decimal.mark = "."),
" (", percentage(sum(grams == "Gram-positive", na.rm = TRUE) / length(grams), digits = digits),
")"),
`No. of genera` = pm_n_distinct(mo_genus(x_noNA, language = NULL)),
`No. of species` = pm_n_distinct(paste(mo_genus(x_noNA, language = NULL),
`Nr. of genera` = pm_n_distinct(mo_genus(x_noNA, language = NULL)),
`Nr. of species` = pm_n_distinct(paste(mo_genus(x_noNA, language = NULL),
mo_species(x_noNA, language = NULL)))))
}
# will be exported using s3_register() in R/zzz.R
get_skimmers.mo <- function(column) {
sfl <- import_fn("sfl", "skimr", error_on_fail = FALSE)
sfl(
skim_type = "mo",
unique_total = n_unique,
gram_negative = ~sum(mo_gramstain(stats::na.omit(.), language = NULL) == "Gram-negative", na.rm = TRUE),
gram_positive = ~sum(mo_gramstain(stats::na.omit(.), language = NULL) == "Gram-positive", na.rm = TRUE),
top_genus = ~names(sort(-table(mo_genus(stats::na.omit(.), language = NULL))))[1L],
top_species = ~names(sort(-table(mo_name(stats::na.omit(.), language = NULL))))[1L]
)
}
#' @method print mo
#' @export
#' @noRd

@ -743,6 +743,43 @@ freq.rsi <- function(x, ...) {
}
}
# will be exported using s3_register() in R/zzz.R
get_skimmers.rsi <- function(column) {
# a bit of a crazy hack to get the variable name
name_call <- function(.data, name = deparse(substitute(column))) {
vars <- tryCatch(eval(parse(text = ".data$skim_variable"), envir = sys.frame(2)),
error = function(e) NULL)
calls <- sys.calls()
i <- tryCatch(attributes(calls[[length(calls)]])$position,
error = function(e) NULL)
if (is.null(vars) | is.null(i)) {
NA_character_
} else{
lengths <- sapply(vars, length)
lengths <- sum(lengths[!names(lengths) == "rsi"])
var <- vars$rsi[i - lengths]
if (var == "data") {
NA_character_
} else{
ab_name(var)
}
}
}
sfl <- import_fn("sfl", "skimr", error_on_fail = FALSE)
sfl(
skim_type = "rsi",
name = name_call,
count_R = count_R,
count_S = count_susceptible,
count_I = count_I,
prop_R = ~proportion_R(., minimum = 0),
prop_S = ~susceptibility(., minimum = 0),
prop_I = ~proportion_I(., minimum = 0)
)
}
#' @method print rsi
#' @export
#' @noRd

@ -151,9 +151,10 @@ rsi_calc <- function(...,
data_vars <- paste(" for", data_vars)
}
warning("Introducing NA: only ", denominator, " results available", data_vars, " (`minimum` = ", minimum, ").", call. = FALSE)
fraction <- NA
fraction <- NA_real_
} else {
fraction <- numerator / denominator
fraction[is.nan(fraction)] <- NA_real_
}
if (as_percent == TRUE) {

@ -49,9 +49,14 @@
s3_register("tibble::type_sum", "mic")
s3_register("pillar::pillar_shaft", "disk")
s3_register("tibble::type_sum", "disk")
# support for frequency tables
# support for frequency tables from the cleaner package
s3_register("cleaner::freq", "mo")
s3_register("cleaner::freq", "rsi")
# support from skim from the skimr package
s3_register("skimr::get_skimmers", "mo")
s3_register("skimr::get_skimmers", "rsi")
s3_register("skimr::get_skimmers", "mic")
s3_register("skimr::get_skimmers", "disk")
}
.onAttach <- function(...) {

@ -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.3.0.9031</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</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.3.0.9031</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</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.3.0.9031</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</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.3.0.9031</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</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.3.0.9031</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</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.3.0.9031</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</span>
</span>
</div>
@ -236,13 +236,13 @@
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div>
<div id="amr-1309031" class="section level1">
<h1 class="page-header" data-toc-text="1.3.0.9031">
<a href="#amr-1309031" class="anchor"></a>AMR 1.3.0.9031<small> Unreleased </small>
<div id="amr-1309032" class="section level1">
<h1 class="page-header" data-toc-text="1.3.0.9032">
<a href="#amr-1309032" class="anchor"></a>AMR 1.3.0.9032<small> Unreleased </small>
</h1>
<div id="last-updated-26-september-2020" class="section level2">
<div id="last-updated-28-september-2020" class="section level2">
<h2 class="hasAnchor">
<a href="#last-updated-26-september-2020" class="anchor"></a><small>Last updated: 26 September 2020</small>
<a href="#last-updated-28-september-2020" class="anchor"></a><small>Last updated: 28 September 2020</small>
</h2>
<p>Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly!</p>
<div id="new" class="section level3">
@ -264,6 +264,7 @@
</pre></div>
</li>
<li><p>Support for veterinary ATC codes</p></li>
<li><p>Support for skimming classes <code>&lt;rsi&gt;</code>, <code>&lt;mic&gt;</code>, <code>&lt;disk&gt;</code> and <code>&lt;mo&gt;</code> with the <code>skimr</code> package</p></li>
</ul>
</div>
<div id="changed" class="section level3">

@ -2,7 +2,7 @@ pandoc: 2.7.3
pkgdown: 1.5.1.9000
pkgdown_sha: eae56f08694abebf93cdfc0dd8e9ede06d8c815f
articles: []
last_built: 2020-09-26T14:51Z
last_built: 2020-09-27T23:07Z
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.3.0.9031</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</span>
</span>
</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.3.0.9029</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</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.3.0.9031</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</span>
</span>
</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.3.0.9029</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</span>
</span>
</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.3.0.9031</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</span>
</span>
</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.3.0.9031</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</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.3.0.9031</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</span>
</span>
</div>

@ -45,7 +45,6 @@ test_that("joins work", {
expect_true(nrow(unjoined) < nrow(right))
expect_true(nrow(unjoined) < nrow(full))
expect_equal(nrow(inner_join_microorganisms("B_ESCHR_COLI")), 1)
expect_equal(nrow(inner_join_microorganisms("B_ESCHR_COLI", by = c("mo" = "mo"))), 1)

@ -28,7 +28,6 @@ test_that("rsi works", {
expect_true(as.rsi("I") < as.rsi("R"))
expect_true(is.rsi(as.rsi("S")))
x <- example_isolates$AMX
expect_s3_class(x[1], "rsi")
expect_s3_class(x[[1]], "rsi")
@ -69,6 +68,14 @@ test_that("rsi works", {
expect_error(as.rsi.disk(as.disk(16)))
expect_error(get_guideline("this one does not exist"))
expect_s3_class(example_isolates %>%
mutate(m = as.mic(2),
d = as.disk(20)) %>%
skimr::skim(),
"data.frame")
expect_s3_class(skimr::skim(example_isolates),
"data.frame")
})

Loading…
Cancel
Save