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

(v1.6.0.9050) printing NA in custom_eucast_rules()

This commit is contained in:
dr. M.S. (Matthijs) Berends 2021-05-20 10:10:40 +02:00
parent 9a2879cba9
commit 04ef5b28e7
21 changed files with 71 additions and 64 deletions

View File

@ -96,7 +96,7 @@ jobs:
- name: Install Linux dependencies - name: Install Linux dependencies
if: runner.os == 'Linux' if: runner.os == 'Linux'
# update the below with sysreqs::sysreqs("DESCRIPTION") and check the "DEB" entries (for Ubuntu). # update the below with sysreqs::sysreqs("DESCRIPTION") and check the "DEB" entries (for Ubuntu).
# we don't want to depend on the sysreqs pkg here, as it requires a quite new R version # we don't want to depend on the sysreqs pkg here, as it requires quite a recent R version
# as of May 2021: https://sysreqs.r-hub.io/pkg/AMR,R,cleaner,curl,dplyr,ggplot2,ggtext,knitr,microbenchmark,pillar,readxl,rmarkdown,rstudioapi,rvest,skimr,tidyr,tinytest,xml2,backports,crayon,rlang,vctrs,evaluate,highr,markdown,stringr,yaml,xfun,cli,ellipsis,fansi,lifecycle,utf8,glue,mime,magrittr,stringi,generics,R6,tibble,tidyselect,pkgconfig,purrr,digest,gtable,isoband,MASS,mgcv,scales,withr,nlme,Matrix,farver,labeling,munsell,RColorBrewer,viridisLite,lattice,colorspace,gridtext,Rcpp,RCurl,png,jpeg,bitops,cellranger,progress,rematch,hms,prettyunits,htmltools,jsonlite,tinytex,base64enc,httr,selectr,openssl,askpass,sys,repr,cpp11 # as of May 2021: https://sysreqs.r-hub.io/pkg/AMR,R,cleaner,curl,dplyr,ggplot2,ggtext,knitr,microbenchmark,pillar,readxl,rmarkdown,rstudioapi,rvest,skimr,tidyr,tinytest,xml2,backports,crayon,rlang,vctrs,evaluate,highr,markdown,stringr,yaml,xfun,cli,ellipsis,fansi,lifecycle,utf8,glue,mime,magrittr,stringi,generics,R6,tibble,tidyselect,pkgconfig,purrr,digest,gtable,isoband,MASS,mgcv,scales,withr,nlme,Matrix,farver,labeling,munsell,RColorBrewer,viridisLite,lattice,colorspace,gridtext,Rcpp,RCurl,png,jpeg,bitops,cellranger,progress,rematch,hms,prettyunits,htmltools,jsonlite,tinytex,base64enc,httr,selectr,openssl,askpass,sys,repr,cpp11
run: | run: |
sudo apt install -y libssl-dev pandoc pandoc-citeproc libxml2-dev libicu-dev libcurl4-openssl-dev libpng-dev sudo apt install -y libssl-dev pandoc pandoc-citeproc libxml2-dev libicu-dev libcurl4-openssl-dev libpng-dev
@ -109,29 +109,33 @@ jobs:
path: ${{ env.R_LIBS_USER }} path: ${{ env.R_LIBS_USER }}
key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-v4 key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-v4
- name: Install AMR and tinytest and update dependencies - name: Unpack AMR and install R dependencies
if: always()
run: | run: |
tar -xf data-raw/AMR_latest.tar.gz
source("data-raw/_install_deps.R") source("data-raw/_install_deps.R")
shell: Rscript {0} shell: Rscript {0}
- name: Show session info - name: Show session info
if: always()
run: | run: |
options(width = 100) options(width = 100)
utils::sessionInfo() utils::sessionInfo()
as.data.frame(utils::installed.packages())[, "Version", drop = FALSE] as.data.frame(utils::installed.packages())[, "Version", drop = FALSE]
shell: Rscript {0} shell: Rscript {0}
- name: Unpack shipped version and remove vignettes - name: Only keep vignettes on release version
if: always() if: matrix.config.r != 'release'
# writing to DESCRIPTION2 and then moving to DESCRIPTION is required for R < 3.3 as writeLines() cannot overwrite
run: | run: |
tar -xf data-raw/AMR_latest.tar.gz
rm -rf AMR/vignettes rm -rf AMR/vignettes
Rscript -e "writeLines(readLines('AMR/DESCRIPTION')[!grepl('VignetteBuilder', readLines('AMR/DESCRIPTION'))], 'AMR/DESCRIPTION')" Rscript -e "writeLines(readLines('AMR/DESCRIPTION')[!grepl('VignetteBuilder', readLines('AMR/DESCRIPTION'))], 'AMR/DESCRIPTION2')"
Rscript -e "writeLines(readLines('AMR/DESCRIPTION')[gsub(' +', '', readLines('AMR/DESCRIPTION')) != ''], 'AMR/DESCRIPTION')" rm AMR/DESCRIPTION
find AMR -name 'DESCRIPTION' -exec cat '{}' \; || true mv AMR/DESCRIPTION2 AMR/DESCRIPTION
shell: bash shell: bash
- name: Run R CMD check - name: Run R CMD check
if: always()
env: env:
_R_CHECK_CRAN_INCOMING_: false _R_CHECK_CRAN_INCOMING_: false
_R_CHECK_FORCE_SUGGESTS_: false _R_CHECK_FORCE_SUGGESTS_: false
@ -142,7 +146,7 @@ jobs:
R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }} R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }}
R_RUN_TINYTEST: true R_RUN_TINYTEST: true
run: | run: |
R CMD check --no-manual --no-vignettes --no-build-vignettes --ignore-vignettes AMR R CMD check --no-manual AMR
shell: bash shell: bash
- name: Show unit tests output - name: Show unit tests output

View File

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 1.6.0.9049 Version: 1.6.0.9050
Date: 2021-05-19 Date: 2021-05-20
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"),

View File

@ -1,5 +1,5 @@
# `AMR` 1.6.0.9049 # `AMR` 1.6.0.9050
## <small>Last updated: 19 May 2021</small> ## <small>Last updated: 20 May 2021</small>
### Breaking change ### Breaking change
* All antibiotic class selectors (such as `carbapenems()`, `aminoglycosides()`) can now be used for filtering as well, making all their accompanying `filter_*()` functions redundant (such as `filter_carbapenems()`, `filter_aminoglycosides()`). These functions are now deprecated and will be removed in a next release. * All antibiotic class selectors (such as `carbapenems()`, `aminoglycosides()`) can now be used for filtering as well, making all their accompanying `filter_*()` functions redundant (such as `filter_carbapenems()`, `filter_aminoglycosides()`). These functions are now deprecated and will be removed in a next release.

View File

@ -56,7 +56,7 @@
#' - `"TU"` = thousand units #' - `"TU"` = thousand units
#' - `"MU"` = million units #' - `"MU"` = million units
#' - `"mmol"` = millimole #' - `"mmol"` = millimole
#' - `"ml"` = milliliter (e.g. eyedrops) #' - `"ml"` = millilitre (e.g. eyedrops)
#' #'
#' **N.B. This function requires an internet connection and only works if the following packages are installed: `curl`, `rvest`, `xml2`.** #' **N.B. This function requires an internet connection and only works if the following packages are installed: `curl`, `rvest`, `xml2`.**
#' @export #' @export

View File

@ -150,7 +150,6 @@ custom_eucast_rules <- function(...) {
result_group <- tryCatch( result_group <- tryCatch(
suppressWarnings(as.ab(result_group, suppressWarnings(as.ab(result_group,
fast_mode = TRUE, fast_mode = TRUE,
info = FALSE,
flag_multiple_results = FALSE)), flag_multiple_results = FALSE)),
error = function(e) NA_character_) error = function(e) NA_character_)
} }
@ -203,7 +202,9 @@ print.custom_eucast_rules <- function(x, ...) {
for (i in seq_len(length(x))) { for (i in seq_len(length(x))) {
rule <- x[[i]] rule <- x[[i]]
rule$query <- format_custom_query_rule(rule$query) rule$query <- format_custom_query_rule(rule$query)
if (rule$result_value == "R") { if (is.na(rule$result_value)) {
val <- font_red("<NA>")
} else if (rule$result_value == "R") {
val <- font_rsi_R_bg(font_black(" R ")) val <- font_rsi_R_bg(font_black(" R "))
} else if (rule$result_value == "S") { } else if (rule$result_value == "S") {
val <- font_rsi_S_bg(font_black(" S ")) val <- font_rsi_S_bg(font_black(" S "))

Binary file not shown.

View File

@ -23,32 +23,31 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== # # ==================================================================== #
install.packages("data-raw/AMR_latest.tar.gz", dependencies = FALSE)
# some old R instances have trouble installing tinytest, so we ship it too # some old R instances have trouble installing tinytest, so we ship it too
install.packages("data-raw/tinytest_1.2.4.patched.tar.gz") install.packages("data-raw/tinytest_1.2.4.patched.tar.gz")
pkg_suggests <- AMR:::trimws(unlist(strsplit(packageDescription("AMR")$Suggests, ",(\n)?"))) descr <- readLines("AMR/DESCRIPTION")
pkg_suggests <- gsub(".*Suggests: (.*)*?[A-Z].*", "\\1", paste0(descr, "*", collapse = ""), perl = FALSE)
pkg_suggests <- unlist(strsplit(pkg_suggests, "[,* ]"))
pkg_suggests <- pkg_suggests[pkg_suggests != ""]
cat("Packages listed in Suggests:", paste(pkg_suggests, collapse = ", "), "\n")
to_install <- pkg_suggests[!pkg_suggests %in% rownames(utils::installed.packages())] to_install <- pkg_suggests[!pkg_suggests %in% rownames(utils::installed.packages())]
to_update <- as.data.frame(utils::old.packages(repos = "https://cran.rstudio.com/"), stringsAsFactors = FALSE) to_update <- as.data.frame(utils::old.packages(repos = "https://cran.rstudio.com/"), stringsAsFactors = FALSE)
to_update <- to_update[which(to_update$Package %in% pkg_suggests), "Package", drop = TRUE]
for (i in seq_len(length(to_install))) { for (i in seq_len(length(to_install))) {
if (isTRUE(is.character(to_install[i]))) {
cat("Installing package", to_install[i], "\n") cat("Installing package", to_install[i], "\n")
tryCatch(install.packages(to_install[i], repos = "https://cran.rstudio.com/", dependencies = TRUE, quiet = TRUE), tryCatch(install.packages(to_install[i], repos = "https://cran.rstudio.com/", dependencies = TRUE, quiet = TRUE),
# message = function(m) invisible(), # message = function(m) invisible(),
warning = function(w) message(w$message), warning = function(w) message(w$message),
error = function(e) message(e$message)) error = function(e) message(e$message))
} }
}
for (i in seq_len(length(to_update))) { for (i in seq_len(length(to_update))) {
if (isTRUE(is.character(to_update[i]))) {
cat("Updating package", to_update[i], "\n") cat("Updating package", to_update[i], "\n")
tryCatch(update.packages(to_update[i], repos = "https://cran.rstudio.com/", ask = FALSE), tryCatch(update.packages(to_update[i], repos = "https://cran.rstudio.com/", ask = FALSE),
# message = function(m) invisible(), # message = function(m) invisible(),
warning = function(w) message(w$message), warning = function(w) message(w$message),
error = function(e) message(e$message)) error = function(e) message(e$message))
} }
}

View File

@ -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.9049</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9050</span>
</span> </span>
</div> </div>

View File

@ -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.9049</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9050</span>
</span> </span>
</div> </div>

View File

@ -39,7 +39,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.9049</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9050</span>
</span> </span>
</div> </div>
@ -192,7 +192,7 @@
<div class="page-header toc-ignore"> <div class="page-header toc-ignore">
<h1 data-toc-skip>Data sets for download / own use</h1> <h1 data-toc-skip>Data sets for download / own use</h1>
<h4 class="date">19 May 2021</h4> <h4 class="date">20 May 2021</h4>
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/datasets.Rmd"><code>vignettes/datasets.Rmd</code></a></small> <small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/datasets.Rmd"><code>vignettes/datasets.Rmd</code></a></small>
<div class="hidden name"><code>datasets.Rmd</code></div> <div class="hidden name"><code>datasets.Rmd</code></div>

View File

@ -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.9049</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9050</span>
</span> </span>
</div> </div>

View File

@ -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.9049</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9050</span>
</span> </span>
</div> </div>

View File

@ -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.9049</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9050</span>
</span> </span>
</div> </div>

View File

@ -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.9049</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9050</span>
</span> </span>
</div> </div>
@ -236,12 +236,12 @@
<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-1609049" class="section level1"> <div id="amr-1609050" class="section level1">
<h1 class="page-header" data-toc-text="1.6.0.9049"> <h1 class="page-header" data-toc-text="1.6.0.9050">
<a href="#amr-1609049" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9049</h1> <a href="#amr-1609050" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9050</h1>
<div id="last-updated-19-may-2021" class="section level2"> <div id="last-updated-20-may-2021" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">
<a href="#last-updated-19-may-2021" class="anchor"></a><small>Last updated: 19 May 2021</small> <a href="#last-updated-20-may-2021" class="anchor"></a><small>Last updated: 20 May 2021</small>
</h2> </h2>
<div id="breaking-change" class="section level3"> <div id="breaking-change" class="section level3">
<h3 class="hasAnchor"> <h3 class="hasAnchor">

View File

@ -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-05-19T21:58Z last_built: 2021-05-20T08:10Z
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

View File

@ -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.9021</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9050</span>
</span> </span>
</div> </div>
@ -309,7 +309,7 @@
<li><p><code>"TU"</code> = thousand units</p></li> <li><p><code>"TU"</code> = thousand units</p></li>
<li><p><code>"MU"</code> = million units</p></li> <li><p><code>"MU"</code> = million units</p></li>
<li><p><code>"mmol"</code> = millimole</p></li> <li><p><code>"mmol"</code> = millimole</p></li>
<li><p><code>"ml"</code> = milliliter (e.g. eyedrops)</p></li> <li><p><code>"ml"</code> = millilitre (e.g. eyedrops)</p></li>
</ul> </ul>
<p><strong>N.B. This function requires an internet connection and only works if the following packages are installed: <code>curl</code>, <code>rvest</code>, <code>xml2</code>.</strong></p> <p><strong>N.B. This function requires an internet connection and only works if the following packages are installed: <code>curl</code>, <code>rvest</code>, <code>xml2</code>.</strong></p>

View File

@ -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.9049</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9050</span>
</span> </span>
</div> </div>

View File

@ -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.9049</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9050</span>
</span> </span>
</div> </div>

View File

@ -23,7 +23,10 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== # # ==================================================================== #
if (tryCatch(curl::has_internet(), error = function(e) FALSE)) { if (pkg_is_available("curl", also_load = FALSE) &&
pkg_is_available("rvest", also_load = FALSE) &&
pkg_is_available("xml2", also_load = FALSE) &&
tryCatch(curl::has_internet(), error = function(e) FALSE)) {
expect_true(length(atc_online_groups(ab_atc("AMX"))) >= 1) expect_true(length(atc_online_groups(ab_atc("AMX"))) >= 1)
expect_equal(atc_online_ddd(ab_atc("AMX"), administration = "O"), 1.5) expect_equal(atc_online_ddd(ab_atc("AMX"), administration = "O"), 1.5)
expect_equal(atc_online_ddd(ab_atc("AMX"), administration = "P"), 3) expect_equal(atc_online_ddd(ab_atc("AMX"), administration = "P"), 3)

View File

@ -35,6 +35,7 @@ expect_equal(proportion_R(example_isolates$AMX) + proportion_I(example_isolates$
expect_equal(proportion_S(example_isolates$AMX) + proportion_I(example_isolates$AMX), expect_equal(proportion_S(example_isolates$AMX) + proportion_I(example_isolates$AMX),
proportion_SI(example_isolates$AMX)) proportion_SI(example_isolates$AMX))
if (pkg_is_available("dplyr")) {
expect_equal(example_isolates %>% proportion_SI(AMC), expect_equal(example_isolates %>% proportion_SI(AMC),
0.7626397, 0.7626397,
tolerance = 0.0001) tolerance = 0.0001)
@ -45,7 +46,6 @@ expect_equal(example_isolates %>% proportion_SI(AMC, GEN, only_all_tested = TRUE
0.9382647, 0.9382647,
tolerance = 0.0001) tolerance = 0.0001)
if (pkg_is_available("dplyr")) {
# percentages # percentages
expect_equal(example_isolates %>% expect_equal(example_isolates %>%
group_by(hospital_id) %>% group_by(hospital_id) %>%

View File

@ -61,7 +61,7 @@ Abbreviations of return values when using \code{property = "U"} (unit):
\item \code{"TU"} = thousand units \item \code{"TU"} = thousand units
\item \code{"MU"} = million units \item \code{"MU"} = million units
\item \code{"mmol"} = millimole \item \code{"mmol"} = millimole
\item \code{"ml"} = milliliter (e.g. eyedrops) \item \code{"ml"} = millilitre (e.g. eyedrops)
} }
\strong{N.B. This function requires an internet connection and only works if the following packages are installed: \code{curl}, \code{rvest}, \code{xml2}.} \strong{N.B. This function requires an internet connection and only works if the following packages are installed: \code{curl}, \code{rvest}, \code{xml2}.}