Browse Source

(v1.7.1.9022) rely on vctrs for ab selectors

v1.8.2
parent
commit
4e1efd902c
  1. 5
      DESCRIPTION
  2. 53
      NEWS.md
  3. 23
      R/aa_helper_functions.R
  4. 25
      R/ab_class_selectors.R
  5. 2
      R/count.R
  6. 1
      R/eucast_rules.R
  7. 4
      R/first_isolate.R
  8. 5
      R/ggplot_rsi.R
  9. 2
      R/guess_ab_col.R
  10. 6
      R/italicise_taxonomy.R
  11. 1
      R/key_antimicrobials.R
  12. 11
      R/mdro.R
  13. 2
      R/mo_property.R
  14. 6
      R/plot.R
  15. 52
      R/random.R
  16. 12
      R/rsi.R
  17. 1
      R/rsi_calc.R
  18. BIN
      R/sysdata.rda
  19. 74
      R/vctrs.R
  20. 17
      R/zzz.R
  21. 1
      _pkgdown.yml
  22. BIN
      data-raw/AMR_latest.tar.gz
  23. 4
      data-raw/translations.tsv
  24. 167
      docs/404.html
  25. 16
      docs/LICENSE-text.html
  26. 730
      docs/articles/AMR.html
  27. BIN
      docs/articles/AMR_files/figure-html/disk_plots-1.png
  28. BIN
      docs/articles/AMR_files/figure-html/disk_plots_mo_ab-1.png
  29. BIN
      docs/articles/AMR_files/figure-html/mic_plots-1.png
  30. BIN
      docs/articles/AMR_files/figure-html/mic_plots-2.png
  31. BIN
      docs/articles/AMR_files/figure-html/mic_plots_mo_ab-1.png
  32. BIN
      docs/articles/AMR_files/figure-html/mic_plots_mo_ab-2.png
  33. BIN
      docs/articles/AMR_files/figure-html/plot 1-1.png
  34. BIN
      docs/articles/AMR_files/figure-html/plot 3-1.png
  35. BIN
      docs/articles/AMR_files/figure-html/plot 4-1.png
  36. BIN
      docs/articles/AMR_files/figure-html/plot 5-1.png
  37. 66
      docs/articles/EUCAST.html
  38. 12
      docs/articles/EUCAST_files/header-attrs-2.9/header-attrs.js
  39. 200
      docs/articles/MDR.html
  40. 12
      docs/articles/MDR_files/header-attrs-2.9/header-attrs.js
  41. 82
      docs/articles/PCA.html
  42. 12
      docs/articles/PCA_files/header-attrs-2.9/header-attrs.js
  43. 124
      docs/articles/SPSS.html
  44. 12
      docs/articles/SPSS_files/header-attrs-2.9/header-attrs.js
  45. 86
      docs/articles/WHONET.html
  46. 12
      docs/articles/WHONET_files/header-attrs-2.9/header-attrs.js
  47. 172
      docs/articles/benchmarks.html
  48. BIN
      docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png
  49. 12
      docs/articles/benchmarks_files/header-attrs-2.9/header-attrs.js
  50. 170
      docs/articles/datasets.html
  51. 16
      docs/articles/index.html
  52. 80
      docs/articles/resistance_predict.html
  53. 12
      docs/articles/resistance_predict_files/header-attrs-2.9/header-attrs.js
  54. 54
      docs/articles/welcome_to_AMR.html
  55. 12
      docs/articles/welcome_to_AMR_files/header-attrs-2.9/header-attrs.js
  56. 19
      docs/authors.html
  57. 5
      docs/extra.css
  58. 11
      docs/extra.js
  59. 118
      docs/index.html
  60. 1064
      docs/news/index.html
  61. BIN
      docs/package-logo.png
  62. 22
      docs/pkgdown.css
  63. 2
      docs/pkgdown.js
  64. 10
      docs/pkgdown.yml
  65. 52
      docs/reference/AMR-deprecated.html
  66. 48
      docs/reference/AMR.html
  67. 52
      docs/reference/WHOCC.html
  68. 50
      docs/reference/WHONET.html
  69. 72
      docs/reference/ab_from_text.html
  70. 24
      docs/reference/ab_property.html
  71. 54
      docs/reference/age.html
  72. 54
      docs/reference/age_groups.html
  73. 26
      docs/reference/antibiotic_class_selectors.html
  74. 182
      docs/reference/antibiotics.html
  75. 56
      docs/reference/as.ab.html
  76. 56
      docs/reference/as.disk.html
  77. 64
      docs/reference/as.mic.html
  78. 66
      docs/reference/as.mo.html
  79. 42
      docs/reference/as.rsi.html
  80. 56
      docs/reference/atc_online.html
  81. 54
      docs/reference/availability.html
  82. 24
      docs/reference/bug_drug_combinations.html
  83. 52
      docs/reference/catalogue_of_life.html
  84. 50
      docs/reference/catalogue_of_life_version.html
  85. 68
      docs/reference/count.html
  86. 44
      docs/reference/custom_eucast_rules.html
  87. 50
      docs/reference/dosage.html
  88. 32
      docs/reference/eucast_rules.html
  89. 50
      docs/reference/example_isolates.html
  90. 50
      docs/reference/example_isolates_unclean.html
  91. 34
      docs/reference/first_isolate.html
  92. 75
      docs/reference/g.test.html
  93. 56
      docs/reference/get_episode.html
  94. 56
      docs/reference/ggplot_pca.html
  95. 58
      docs/reference/ggplot_rsi.html
  96. 56
      docs/reference/guess_ab_col.html
  97. 18
      docs/reference/index.html
  98. 54
      docs/reference/intrinsic_resistant.html
  99. 62
      docs/reference/italicise_taxonomy.html
  100. 24
      docs/reference/join.html
  101. Some files were not shown because too many files have changed in this diff Show More

5
DESCRIPTION

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
Package: AMR
Version: 1.7.1.9021
Date: 2021-07-12
Version: 1.7.1.9022
Date: 2021-07-23
Title: Antimicrobial Resistance Data Analysis
Authors@R: c(
person(role = c("aut", "cre"),
@ -57,6 +57,7 @@ Suggests: @@ -57,6 +57,7 @@ Suggests:
skimr,
tidyr,
tinytest,
vctrs,
xml2
VignetteBuilder: knitr,rmarkdown
URL: https://github.com/msberends/AMR, https://msberends.github.io/AMR

53
NEWS.md

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
# `AMR` 1.7.1.9021
## <small>Last updated: 12 July 2021</small>
# `AMR` 1.7.1.9022
## <small>Last updated: 23 July 2021</small>
### Changed
* Previously implemented `ggplot2::gggplot()` generics for classes `<mic>`, `<disk>`, `<rsi>` and `<resistance_predict>` did not follow the `ggplot2` logic, and were replaced with `autoplot()` generics.
* Previously implemented `ggplot2::ggplot()` generics for classes `<mic>`, `<disk>`, `<rsi>` and `<resistance_predict>` did not follow the `ggplot2` logic, and were replaced with `autoplot()` generics.
* Antibiotic class selectors (see `ab_class()`)
* They now also work in R-3.0 and R-3.1, supporting every version of R since 2013
* Added more selectors: `aminopenicillins()`, `lincosamides()`, `lipoglycopeptides()`, `polymyxins()`, `quinolones()`, `streptogramins()` and `ureidopenicillins()`
@ -17,12 +17,13 @@ @@ -17,12 +17,13 @@
* `as.rsi()` can now correct for textual input (such as "Susceptible", "Resistant") in Dutch, English, French, German, Italian, Portuguese and Spanish
* When warnings are thrown because of too few isolates in any `count_*()`, `proportion_*()` function (or `resistant()` or `susceptible()`), the `dplyr` group will be shown, if available
* `ab_name()` gained argument `snake_case`, which is useful for column renaming
* Fix for legends created with `scale_rsi_colours()` when using `ggplot2` v3.3.4 or higher (this is bug ggplot2#4511, soon to be fixed)
* Fix for legends created with `scale_rsi_colours()` when using `ggplot2` v3.3.4 or higher (this is ggplot2 bug 4511, soon to be fixed)
* Fix for minor translation errors
* Fix for the MIC interpretation of *Morganellaceae* (such as *Morganella* and *Proteus*) when using the EUCAST 2021 guideline
* Improved algorithm for generating random MICs with `random_mic()`
* Improved plot legends for MICs and disk diffusion values
# `AMR` 1.7.1
# AMR 1.7.1
### 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. Examples of how the selectors can be used for filtering:
@ -96,7 +97,7 @@ @@ -96,7 +97,7 @@
* All unit tests are now processed by the `tinytest` package, instead of the `testthat` package. The `testthat` package unfortunately requires tons of dependencies that are also heavy and only usable for recent R versions, disallowing developers to test a package under any R 3.* version. On the contrary, the `tinytest` package is very lightweight and dependency-free.
# `AMR` 1.6.0
# AMR 1.6.0
### New
* Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the `eucast_rules()` function and in `as.rsi()` to interpret MIC and disk diffusion values. This is now the default guideline in this package.
@ -190,7 +191,7 @@ @@ -190,7 +191,7 @@
* Loading the package (i.e., `library(AMR)`) now is ~50 times faster than before, in costs of package size (which increased by ~3 MB)
# `AMR` 1.5.0
# AMR 1.5.0
### New
* Functions `get_episode()` and `is_new_episode()` to determine (patient) episodes which are not necessarily based on microorganisms. The `get_episode()` function returns the index number of the episode per group, while the `is_new_episode()` function returns values `TRUE`/`FALSE` to indicate whether an item in a vector is the start of a new episode. They also support `dplyr`s grouping (i.e. using `group_by()`):
@ -267,7 +268,7 @@ @@ -267,7 +268,7 @@
* Added CodeFactor as a continuous code review to this package: <https://www.codefactor.io/repository/github/msberends/amr/>
* Added Dr. Rogier Schade as contributor
# `AMR` 1.4.0
# AMR 1.4.0
### New
* Support for 'EUCAST Expert Rules' / 'EUCAST Intrinsic Resistance and Unusual Phenotypes' version 3.2 of May 2020. With this addition to the previously implemented version 3.1 of 2016, the `eucast_rules()` function can now correct for more than 180 different antibiotics and the `mdro()` function can determine multidrug resistance based on more than 150 different antibiotics. All previously implemented versions of the EUCAST rules are now maintained and kept available in this package. The `eucast_rules()` function consequently gained the arguments `version_breakpoints` (at the moment defaults to v10.0, 2020) and `version_expertrules` (at the moment defaults to v3.2, 2020). The `example_isolates` data set now also reflects the change from v3.1 to v3.2. The `mdro()` function now accepts `guideline == "EUCAST3.1"` and `guideline == "EUCAST3.2"`.
@ -339,7 +340,7 @@ @@ -339,7 +340,7 @@
* Removed unnecessary references to the `base` package
* Added packages that could be useful for some functions to the `Suggests` field of the `DESCRIPTION` file
# `AMR` 1.3.0
# AMR 1.3.0
### New
* Function `ab_from_text()` to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses `as.ab()` internally
@ -392,7 +393,7 @@ @@ -392,7 +393,7 @@
### Other
* Moved primary location of this project from GitLab to [GitHub](https://github.com/msberends/AMR), giving us native support for automated syntax checking without being dependent on external services such as AppVeyor and Travis CI.
# `AMR` 1.2.0
# AMR 1.2.0
### Breaking
* Removed code dependency on all other R packages, making this package fully independent of the development process of others. This is a major code change, but will probably not be noticeable by most users.
@ -430,7 +431,7 @@ @@ -430,7 +431,7 @@
* Removed previously deprecated function `p.symbol()` - it was replaced with `p_symbol()`
* Removed function `read.4d()`, that was only useful for reading data from an old test database.
# `AMR` 1.1.0
# AMR 1.1.0
### New
* Support for easy principal component analysis for AMR, using the new `pca()` function
@ -452,7 +453,7 @@ @@ -452,7 +453,7 @@
* Support for the upcoming `dplyr` version 1.0.0
* More robust assigning for classes `rsi` and `mic`
# `AMR` 1.0.1
# AMR 1.0.1
### Changed
* Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline
@ -468,7 +469,7 @@ @@ -468,7 +469,7 @@
* Added `uti` (as abbreviation of urinary tract infections) as argument to `as.rsi()`, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs
* Info printing in functions `eucast_rules()`, `first_isolate()`, `mdro()` and `resistance_predict()` will now at default only print when R is in an interactive mode (i.e. not in RMarkdown)
# `AMR` 1.0.0
# AMR 1.0.0
This software is now out of beta and considered stable. Nonetheless, this package will be developed continually.
@ -516,7 +517,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag @@ -516,7 +517,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
* Full support for the upcoming R 4.0
* Removed unnecessary `AMR::` calls
# `AMR` 0.9.0
# AMR 0.9.0
### Breaking
* Adopted Adeolu *et al.* (2016), [PMID 27620848](https:/pubmed.ncbi.nlm.nih.gov/27620848/) for the `microorganisms` data set, which means that the new order Enterobacterales now consists of a part of the existing family Enterobacteriaceae, but that this family has been split into other families as well (like *Morganellaceae* and *Yersiniaceae*). Although published in 2016, this information is not yet in the Catalogue of Life version of 2019. All MDRO determinations with `mdro()` will now use the Enterobacterales order for all guidelines before 2016 that were dependent on the Enterobacteriaceae family.
@ -582,7 +583,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag @@ -582,7 +583,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
* Change dependency on `clean` to `cleaner`, as this package was renamed accordingly upon CRAN request
* Added Dr. Sofia Ny as contributor
# `AMR` 0.8.0
# AMR 0.8.0
### Breaking
* Determination of first isolates now **excludes** all 'unknown' microorganisms at default, i.e. microbial code `"UNKNOWN"`. They can be included with the new argument `include_unknown`:
@ -711,7 +712,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag @@ -711,7 +712,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
* Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors
* Cleaned the coding style of every single syntax line in this package with the help of the `lintr` package
# `AMR` 0.7.1
# AMR 0.7.1
#### New
* Function `rsi_df()` to transform a `data.frame` to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions `count_df()` and `portion_df()` to immediately show resistance percentages and number of available isolates:
@ -772,7 +773,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag @@ -772,7 +773,7 @@ This software is now out of beta and considered stable. Nonetheless, this packag
#### Other
* Fixed a note thrown by CRAN tests
# `AMR` 0.7.0
# AMR 0.7.0
#### New
* Support for translation of disk diffusion and MIC values to RSI values (i.e. antimicrobial interpretations). Supported guidelines are EUCAST (2011 to 2019) and CLSI (2011 to 2019). Use `as.rsi()` on an MIC value (created with `as.mic()`), a disk diffusion value (created with the new `as.disk()`) or on a complete date set containing columns with MIC or disk diffusion values.
@ -830,13 +831,13 @@ This software is now out of beta and considered stable. Nonetheless, this packag @@ -830,13 +831,13 @@ This software is now out of beta and considered stable. Nonetheless, this packag
#### Other
* Support for R 3.6.0 and later by providing support for [staged install](https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html)
# `AMR` 0.6.1
# AMR 0.6.1
#### Changed
* Fixed a critical bug when using `eucast_rules()` with `verbose = TRUE`
* Coercion of microbial IDs are now written to the package namespace instead of the user's home folder, to comply with the CRAN policy
# `AMR` 0.6.0
# AMR 0.6.0
**New website!**
@ -1029,7 +1030,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git @@ -1029,7 +1030,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
#### Other
* Updated licence text to emphasise GPL 2.0 and that this is an R package.
# `AMR` 0.5.0
# AMR 0.5.0
#### New
* Repository moved to GitLab
@ -1112,7 +1113,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git @@ -1112,7 +1113,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
* Updated vignettes to comply with README
# `AMR` 0.4.0
# AMR 0.4.0
#### New
* The data set `microorganisms` now contains **all microbial taxonomic data from ITIS** (kingdoms Bacteria, Fungi and Protozoa), the Integrated Taxonomy Information System, available via https://itis.gov. The data set now contains more than 18,000 microorganisms with all known bacteria, fungi and protozoa according ITIS with genus, species, subspecies, family, order, class, phylum and subkingdom. The new data set `microorganisms.old` contains all previously known taxonomic names from those kingdoms.
@ -1223,7 +1224,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git @@ -1223,7 +1224,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
#### Other
* More unit tests to ensure better integrity of functions
# `AMR` 0.3.0
# AMR 0.3.0
#### New
* **BREAKING**: `rsi_df` was removed in favour of new functions `portion_R`, `portion_IR`, `portion_I`, `portion_SI` and `portion_S` to selectively calculate resistance or susceptibility. These functions are 20 to 30 times faster than the old `rsi` function. The old function still works, but is deprecated.
@ -1293,7 +1294,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git @@ -1293,7 +1294,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
* Windows: https://ci.appveyor.com/project/msberends/amr
* Added thesis advisors to DESCRIPTION file
# `AMR` 0.2.0
# AMR 0.2.0
#### New
* Full support for Windows, Linux and macOS
@ -1328,7 +1329,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git @@ -1328,7 +1329,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
* Added build tests for Linux and macOS using Travis CI (https://travis-ci.org/msberends/AMR)
* Added line coverage checking using CodeCov (https://codecov.io/gh/msberends/AMR/tree/master/R)
# `AMR` 0.1.1
# AMR 0.1.1
* `EUCAST_rules` applies for amoxicillin even if ampicillin is missing
* Edited column names to comply with GLIMS, the laboratory information system
@ -1336,6 +1337,6 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git @@ -1336,6 +1337,6 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git
* Renamed 'Daily Defined Dose' to 'Defined Daily Dose'
* Added barplots for `rsi` and `mic` classes
# `AMR` 0.1.0
# AMR 0.1.0
* First submission to CRAN.

23
R/aa_helper_functions.R

@ -135,7 +135,6 @@ check_dataset_integrity <- function() { @@ -135,7 +135,6 @@ check_dataset_integrity <- function() {
" the AMR package from working correctly: ",
vector_and(overwritten, quotes = "'"),
".\nPlease rename your object", plural[3], ".", call = FALSE)
remember_thrown_message("dataset_overwritten")
}
}
# check if other packages did not overwrite our data sets
@ -258,7 +257,6 @@ search_type_in_df <- function(x, type, info = TRUE) { @@ -258,7 +257,6 @@ search_type_in_df <- function(x, type, info = TRUE) {
msg <- paste(msg, "Use", font_bold(paste0("col_", type), "= FALSE"), "to prevent this.")
}
message_(msg)
remember_thrown_message(fn = paste0("search_", type))
}
}
found
@ -771,10 +769,11 @@ get_current_data <- function(arg_name, call) { @@ -771,10 +769,11 @@ get_current_data <- function(arg_name, call) {
} else {
examples <- ""
}
stop_("this function must be used inside valid dplyr selection verbs or inside a data.frame call",
stop_("this function must be used inside a `dplyr` verb or `data.frame` call",
examples,
call = call)
} else {
# mimic a base R error that the argument is missing
stop_("argument `", arg_name, "` is missing with no default", call = call)
}
}
@ -840,16 +839,18 @@ unique_call_id <- function(entire_session = FALSE) { @@ -840,16 +839,18 @@ unique_call_id <- function(entire_session = FALSE) {
}
}
remember_thrown_message <- function(fn, entire_session = FALSE) {
message_not_thrown_before <- function(fn, entire_session = FALSE) {
# this is to prevent that messages/notes will be printed for every dplyr group
# e.g. this would show a msg 4 times: example_isolates %>% group_by(hospital_id) %>% filter(mo_is_gram_negative())
assign(x = paste0("thrown_msg.", fn),
value = unique_call_id(entire_session = entire_session),
envir = pkg_env)
}
message_not_thrown_before <- function(fn, entire_session = FALSE) {
is.null(pkg_env[[paste0("thrown_msg.", fn)]]) || !identical(pkg_env[[paste0("thrown_msg.", fn)]], unique_call_id(entire_session))
test_out <- is.null(pkg_env[[paste0("thrown_msg.", fn)]]) || !identical(pkg_env[[paste0("thrown_msg.", fn)]],
unique_call_id(entire_session = entire_session))
if (isTRUE(test_out)) {
# message was not thrown before - remember this so on the next run it will return FALSE:
assign(x = paste0("thrown_msg.", fn),
value = unique_call_id(entire_session = entire_session),
envir = pkg_env)
}
test_out
}
has_colour <- function() {

25
R/ab_class_selectors.R

@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
#' @details
#' These functions can be used in data set calls for selecting columns and filtering rows. They are heavily inspired by the [Tidyverse selection helpers][tidyselect::language] such as [`everything()`][tidyselect::everything()], but also work in base \R and not only in `dplyr` verbs. Nonetheless, they are very convenient to use with `dplyr` functions such as [`select()`][dplyr::select()], [`filter()`][dplyr::filter()] and [`summarise()`][dplyr::summarise()], see *Examples*.
#'
#' All columns in the data in which these functions are called will be searched for known antibiotic names, abbreviations, brand names, and codes (ATC, EARS-Net, WHO, etc.) in the [antibiotics] data set. This means that a selector such as [aminoglycosides()] will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. Use the [ab_class()] function to filter/select on a manually defined antibiotic class.
#' All columns in the data in which these functions are called will be searched for known antibiotic names, abbreviations, brand names, and codes (ATC, EARS-Net, WHO, etc.) according to the [antibiotics] data set. This means that a selector such as [aminoglycosides()] will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. Use the [ab_class()] function to filter/select on a manually defined antibiotic class.
#'
#' @section Full list of supported agents:
#'
@ -312,7 +312,6 @@ ab_selector <- function(function_name, @@ -312,7 +312,6 @@ ab_selector <- function(function_name,
sort = TRUE), ". They can be included using `", function_name, "(only_treatable = FALSE)`. ",
"This warning will be shown once per session.",
call = FALSE)
remember_thrown_message(paste0("ab_class.untreatable.", function_name), entire_session = TRUE)
}
ab_in_data <- ab_in_data[!names(ab_in_data) %in% untreatable]
}
@ -343,8 +342,8 @@ ab_selector <- function(function_name, @@ -343,8 +342,8 @@ ab_selector <- function(function_name,
# get the columns with a group names in the chosen ab class
agents <- ab_in_data[names(ab_in_data) %in% abx]
if (message_not_thrown_before(paste0(function_name, ".", paste(pkg_env$get_column_abx.out, collapse = "|")))) {
if (message_not_thrown_before(paste0(function_name, ".", paste(sort(agents), collapse = "|")))) {
if (length(agents) == 0) {
message_("No antimicrobial agents of class '", ab_group, "' found", examples, ".")
} else {
@ -360,21 +359,10 @@ ab_selector <- function(function_name, @@ -360,21 +359,10 @@ ab_selector <- function(function_name,
ifelse(length(agents) == 1, "column ", "columns "),
vector_and(agents_formatted, quotes = FALSE, sort = FALSE))
}
remember_thrown_message(paste0(function_name, ".", paste(pkg_env$get_column_abx.out, collapse = "|")))
}
if (!is.null(attributes(vars_df)$type) &&
attributes(vars_df)$type %in% c("dplyr_cur_data_all", "base_R") &&
!any(as.character(sys.calls()) %like% paste0("(across|if_any|if_all)\\((c\\()?[a-z(), ]*", function_name))) {
structure(unname(agents),
class = c("ab_selector", "character"))
} else {
# don't return with "ab_selector" class if method is a dplyr selector,
# dplyr::select() will complain:
# > Subscript has the wrong type `ab_selector`.
# > It must be numeric or character.
unname(agents)
}
structure(unname(agents),
class = c("ab_selector", "character"))
}
#' @method c ab_selector
@ -412,7 +400,6 @@ all_any_ab_selector <- function(type, ..., na.rm = TRUE) { @@ -412,7 +400,6 @@ all_any_ab_selector <- function(type, ..., na.rm = TRUE) {
#' @export
#' @noRd
all.ab_selector <- function(..., na.rm = FALSE) {
# this is all() for
all_any_ab_selector("all", ..., na.rm = na.rm)
}
@ -458,7 +445,6 @@ any.ab_selector_any_all <- function(..., na.rm = FALSE) { @@ -458,7 +445,6 @@ any.ab_selector_any_all <- function(..., na.rm = FALSE) {
`==.ab_selector` <- function(e1, e2) {
calls <- as.character(match.call())
fn_name <- calls[2]
# keep only the ... in c(...)
fn_name <- gsub("^(c\\()(.*)(\\))$", "\\2", fn_name)
if (is_any(fn_name)) {
type <- "any"
@ -481,7 +467,6 @@ any.ab_selector_any_all <- function(..., na.rm = FALSE) { @@ -481,7 +467,6 @@ any.ab_selector_any_all <- function(..., na.rm = FALSE) {
`!=.ab_selector` <- function(e1, e2) {
calls <- as.character(match.call())
fn_name <- calls[2]
# keep only the ... in c(...)
fn_name <- gsub("^(c\\()(.*)(\\))$", "\\2", fn_name)
if (is_any(fn_name)) {
type <- "any"

2
R/count.R

@ -149,7 +149,6 @@ count_R <- function(..., only_all_tested = FALSE) { @@ -149,7 +149,6 @@ count_R <- function(..., only_all_tested = FALSE) {
count_IR <- function(..., only_all_tested = FALSE) {
if (message_not_thrown_before("count_IR", entire_session = TRUE)) {
message_("Using `count_IR()` is discouraged; use `count_resistant()` instead to not consider \"I\" being resistant. This note will be shown once for this session.", as_note = FALSE)
remember_thrown_message("count_IR")
}
tryCatch(
rsi_calc(...,
@ -186,7 +185,6 @@ count_SI <- function(..., only_all_tested = FALSE) { @@ -186,7 +185,6 @@ count_SI <- function(..., only_all_tested = FALSE) {
count_S <- function(..., only_all_tested = FALSE) {
if (message_not_thrown_before("count_S", entire_session = TRUE)) {
message_("Using `count_S()` is discouraged; use `count_susceptible()` instead to also consider \"I\" being susceptible. This note will be shown once for this session.", as_note = FALSE)
remember_thrown_message("count_S")
}
tryCatch(
rsi_calc(...,

1
R/eucast_rules.R

@ -1072,7 +1072,6 @@ eucast_dosage <- function(ab, administration = "iv", version_breakpoints = 11.0) @@ -1072,7 +1072,6 @@ eucast_dosage <- function(ab, administration = "iv", version_breakpoints = 11.0)
message_("Dosages for antimicrobial drugs, as meant for ",
format_eucast_version_nr(version_breakpoints, markdown = FALSE), ". ",
font_red("This note will be shown once per session."))
remember_thrown_message(paste0("eucast_dosage_v", gsub("[^0-9]", "", version_breakpoints)), entire_session = TRUE)
}
ab <- as.ab(ab)

4
R/first_isolate.R

@ -264,7 +264,6 @@ first_isolate <- function(x = NULL, @@ -264,7 +264,6 @@ first_isolate <- function(x = NULL,
"")),
as_note = FALSE,
add_fn = font_black)
remember_thrown_message("first_isolate.method")
}
# try to find columns based on type
@ -364,7 +363,6 @@ first_isolate <- function(x = NULL, @@ -364,7 +363,6 @@ first_isolate <- function(x = NULL,
message_("Excluding test codes: ", toString(paste0("'", testcodes_exclude, "'")),
add_fn = font_black,
as_note = FALSE)
remember_thrown_message("first_isolate.excludingtestcodes")
}
if (is.null(col_specimen)) {
@ -378,7 +376,6 @@ first_isolate <- function(x = NULL, @@ -378,7 +376,6 @@ first_isolate <- function(x = NULL,
message_("Excluding other than specimen group '", specimen_group, "'",
add_fn = font_black,
as_note = FALSE)
remember_thrown_message("first_isolate.excludingspecimen")
}
}
if (!is.null(col_keyantimicrobials)) {
@ -474,7 +471,6 @@ first_isolate <- function(x = NULL, @@ -474,7 +471,6 @@ first_isolate <- function(x = NULL,
add_fn = font_black,
as_note = FALSE)
}
remember_thrown_message("first_isolate.type")
}
type_param <- type

5
R/ggplot_rsi.R

@ -389,10 +389,11 @@ scale_rsi_colours <- function(..., @@ -389,10 +389,11 @@ scale_rsi_colours <- function(...,
names_susceptible <- c("S", "SI", "IS", "S+I", "I+S", "susceptible", "Susceptible",
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Susceptible"),
"replacement", drop = TRUE]))
names_incr_exposure <- c("I", "intermediate", "increased exposure", "incr. exposure", "Increased exposure", "Incr. exposure",
names_incr_exposure <- c("I", "intermediate", "increased exposure", "incr. exposure",
"Increased exposure", "Incr. exposure", "Susceptible, incr. exp.",
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Intermediate"),
"replacement", drop = TRUE]),
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Incr. exposure"),
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Susceptible, incr. exp."),
"replacement", drop = TRUE]))
names_resistant <- c("R", "IR", "RI", "R+I", "I+R", "resistant", "Resistant",
unique(TRANSLATIONS[which(TRANSLATIONS$pattern == "Resistant"),

2
R/guess_ab_col.R

@ -121,7 +121,7 @@ get_column_abx <- function(x, @@ -121,7 +121,7 @@ get_column_abx <- function(x,
# these columns did not exist in the last call, so add them
new_cols_rsi <- get_column_abx(x[, new_cols, drop = FALSE], reuse_previous_result = FALSE, info = FALSE, sort = FALSE)
current <- c(current, new_cols_rsi)
# order according to data in current call
# order according to columns in current call
current <- current[match(colnames(x)[colnames(x) %in% current], current)]
}

6
R/italicise_taxonomy.R

@ -44,11 +44,11 @@ @@ -44,11 +44,11 @@
#' cat(italicise_taxonomy("An overview of S. aureus isolates", type = "ansi"))
#'
#' # since ggplot2 supports no markdown (yet), use
#' # italicise_taxonomy() and the `ggtext` pkg for titles:
#' # italicise_taxonomy() and the `ggtext` package for titles:
#' \donttest{
#' if (require("ggplot2") && require("ggtext")) {
#' ggplot(example_isolates$AMC,
#' title = italicise_taxonomy("Amoxi/clav in E. coli")) +
#' autoplot(example_isolates$AMC,
#' title = italicise_taxonomy("Amoxi/clav in E. coli")) +
#' theme(plot.title = ggtext::element_markdown())
#' }
#' }

1
R/key_antimicrobials.R

@ -177,7 +177,6 @@ key_antimicrobials <- function(x = NULL, @@ -177,7 +177,6 @@ key_antimicrobials <- function(x = NULL,
paste0("Only using ", values_new_length, " out of ", values_old_length, " defined columns ")),
"as key antimicrobials for ", name, "s. See ?key_antimicrobials.",
call = FALSE)
remember_thrown_message(paste0("key_antimicrobials.", name))
}
generate_antimcrobials_string(x[which(filter), c(universal, values), drop = FALSE])

11
R/mdro.R

@ -187,13 +187,9 @@ mdro <- function(x = NULL, @@ -187,13 +187,9 @@ mdro <- function(x = NULL,
check_dataset_integrity()
info.bak <- info
if (message_not_thrown_before("mdro")) {
remember_thrown_message("mdro")
} else {
# don't thrown info's more than once per call
info <- FALSE
}
# don't thrown info's more than once per call
info <- message_not_thrown_before("mdro")
if (interactive() & verbose == TRUE & info == TRUE) {
txt <- paste0("WARNING: In Verbose mode, the mdro() function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.",
"\n\nThis may overwrite your existing data if you use e.g.:",
@ -1416,7 +1412,6 @@ mdro <- function(x = NULL, @@ -1416,7 +1412,6 @@ mdro <- function(x = NULL,
if (message_not_thrown_before("mdro.availability")) {
warning_("NA introduced for isolates where the available percentage of antimicrobial classes was below ",
percentage(pct_required_classes), " (set with `pct_required_classes`)", call = FALSE)
remember_thrown_message("mdro.availability")
}
# set these -1s to NA
x[which(x$MDRO == -1), "MDRO"] <- NA_integer_

2
R/mo_property.R

@ -481,7 +481,6 @@ mo_is_intrinsic_resistant <- function(x, ab, language = get_locale(), ...) { @@ -481,7 +481,6 @@ mo_is_intrinsic_resistant <- function(x, ab, language = get_locale(), ...) {
message_("Determining intrinsic resistance based on ",
format_eucast_version_nr(3.2, markdown = FALSE), ". ",
font_red("This note will be shown once per session."))
remember_thrown_message("intrinsic_resistant_version", entire_session = TRUE)
}
# runs against internal vector: INTRINSIC_R (see zzz.R)
@ -758,7 +757,6 @@ find_mo_col <- function(fn) { @@ -758,7 +757,6 @@ find_mo_col <- function(fn) {
if (!is.null(df) && !is.null(mo) && is.data.frame(df)) {
if (message_not_thrown_before(fn = fn)) {
message_("Using column '", font_bold(mo), "' as input for `", fn, "()`")
remember_thrown_message(fn = fn)
}
return(df[, mo, drop = TRUE])
} else {

6
R/plot.R

@ -265,7 +265,7 @@ autoplot.mic <- function(object, @@ -265,7 +265,7 @@ autoplot.mic <- function(object,
if (any(colours_RSI %in% cols_sub$cols)) {
vals <- c("Resistant" = colours_RSI[1],
"Susceptible" = colours_RSI[2],
"Incr. exposure" = colours_RSI[3],
"Susceptible, incr. exp." = colours_RSI[3],
"Intermediate" = colours_RSI[3])
names(vals) <- translate_AMR(names(vals), language = language)
p <- p +
@ -482,7 +482,7 @@ autoplot.disk <- function(object, @@ -482,7 +482,7 @@ autoplot.disk <- function(object,
if (any(colours_RSI %in% cols_sub$cols)) {
vals <- c("Resistant" = colours_RSI[1],
"Susceptible" = colours_RSI[2],
"Incr. exposure" = colours_RSI[3],
"Susceptible, incr. exp." = colours_RSI[3],
"Intermediate" = colours_RSI[3])
names(vals) <- translate_AMR(names(vals), language = language)
p <- p +
@ -686,7 +686,7 @@ plot_prepare_table <- function(x, expand) { @@ -686,7 +686,7 @@ plot_prepare_table <- function(x, expand) {
plot_name_of_I <- function(guideline) {
if (guideline %unlike% "CLSI" && as.double(gsub("[^0-9]+", "", guideline)) >= 2019) {
# interpretation since 2019
"Incr. exposure"
"Susceptible, incr. exp."
} else {
# interpretation until 2019
"Intermediate"

52
R/random.R

@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
#'
#' These functions can be used for generating random MIC values and disk diffusion diameters, for AMR data analysis practice. By providing a microorganism and antimicrobial agent, the generated results will reflect reality as much as possible.
#' @inheritSection lifecycle Stable Lifecycle
#' @param size desired size of the returned vector
#' @param size desired size of the returned vector. If used in a [data.frame] call or `dplyr` verb, will get the current (group) size if left blank.
#' @param mo any [character] that can be coerced to a valid microorganism code with [as.mo()]
#' @param ab any [character] that can be coerced to a valid antimicrobial agent code with [as.ab()]
#' @param prob_RSI a vector of length 3: the probabilities for R (1st value), S (2nd value) and I (3rd value)
@ -55,27 +55,36 @@ @@ -55,27 +55,36 @@
#' random_disk(100, "Klebsiella pneumoniae", "ampicillin") # range 11-17
#' random_disk(100, "Streptococcus pneumoniae", "ampicillin") # range 12-27
#' }
random_mic <- function(size, mo = NULL, ab = NULL, ...) {
meet_criteria(size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
random_mic <- function(size = NULL, mo = NULL, ab = NULL, ...) {
meet_criteria(size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE, allow_NULL = TRUE)
meet_criteria(mo, allow_class = "character", has_length = 1, allow_NULL = TRUE)
meet_criteria(ab, allow_class = "character", has_length = 1, allow_NULL = TRUE)
if (is.null(size)) {
size <- NROW(get_current_data(arg_name = "size", call = -3))
}
random_exec("MIC", size = size, mo = mo, ab = ab)
}
#' @rdname random
#' @export
random_disk <- function(size, mo = NULL, ab = NULL, ...) {
meet_criteria(size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
random_disk <- function(size = NULL, mo = NULL, ab = NULL, ...) {
meet_criteria(size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE, allow_NULL = TRUE)
meet_criteria(mo, allow_class = "character", has_length = 1, allow_NULL = TRUE)
meet_criteria(ab, allow_class = "character", has_length = 1, allow_NULL = TRUE)
if (is.null(size)) {
size <- NROW(get_current_data(arg_name = "size", call = -3))
}
random_exec("DISK", size = size, mo = mo, ab = ab)
}
#' @rdname random
#' @export
random_rsi <- function(size, prob_RSI = c(0.33, 0.33, 0.33), ...) {
meet_criteria(size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
random_rsi <- function(size = NULL, prob_RSI = c(0.33, 0.33, 0.33), ...) {
meet_criteria(size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE, allow_NULL = TRUE)
meet_criteria(prob_RSI, allow_class = c("numeric", "integer"), has_length = 3)
if (is.null(size)) {
size <- NROW(get_current_data(arg_name = "size", call = -3))
}
sample(as.rsi(c("R", "S", "I")), size = size, replace = TRUE, prob = prob_RSI)
}
@ -111,23 +120,22 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) { @@ -111,23 +120,22 @@ random_exec <- function(type, size, mo = NULL, ab = NULL) {
warning_("No rows found that match ab '", ab, "', ignoring argument `ab`", call = FALSE)
}
}
if (type == "MIC") {
# all valid MIC levels
valid_range <- as.mic(levels(as.mic(1)))
set_range_max <- max(df$breakpoint_R)
if (log(set_range_max, 2) %% 1 == 0) {
# return powers of 2
valid_range <- unique(as.double(valid_range))
# add 1-3 higher MIC levels to set_range_max
set_range_max <- 2 ^ (log(set_range_max, 2) + sample(c(1:3), 1))
set_range <- as.mic(valid_range[log(valid_range, 2) %% 1 == 0 & valid_range <= set_range_max])
} else {
# no power of 2, return factors of 2 to left and right side
valid_mics <- suppressWarnings(as.mic(set_range_max / (2 ^ c(-3:3))))
set_range <- valid_mics[!is.na(valid_mics)]
# set range
mic_range <- c(0.001, 0.002, 0.005, 0.010, 0.025, 0.0625, 0.125, 0.250, 0.5, 1, 2, 4, 8, 16, 32, 64, 128, 256)
# get highest/lowest +/- random 1 to 3 higher factors of two
max_range <- mic_range[min(length(mic_range),
which(mic_range == max(df$breakpoint_R)) + sample(c(1:3), 1))]
min_range <- mic_range[max(1,
which(mic_range == min(df$breakpoint_S)) - sample(c(1:3), 1))]
mic_range_new <- mic_range[mic_range <= max_range & mic_range >= min_range]
if (length(mic_range_new) == 0) {
mic_range_new <- mic_range
}
out <- as.mic(sample(set_range, size = size, replace = TRUE))
out <- as.mic(sample(mic_range_new, size = size, replace = TRUE))
# 50% chance that lowest will get <= and highest will get >=
if (stats::runif(1) > 0.5) {
out[out == min(out)] <- paste0("<=", out[out == min(out)])

12
R/rsi.R

@ -294,16 +294,15 @@ as.rsi.default <- function(x, ...) { @@ -294,16 +294,15 @@ as.rsi.default <- function(x, ...) {
LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED %in% colnames(TRANSLATIONS)]])
trans_S <- unlist(TRANSLATIONS[which(TRANSLATIONS$pattern == "Susceptible"),
LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED %in% colnames(TRANSLATIONS)]])
trans_I <- unlist(TRANSLATIONS[which(TRANSLATIONS$pattern %in% c("Incr. exposure", "Intermediate")),
trans_I <- unlist(TRANSLATIONS[which(TRANSLATIONS$pattern %in% c("Incr. exposure", "Susceptible, incr. exp.", "Intermediate")),
LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED %in% colnames(TRANSLATIONS)]])
x <- gsub(paste0(unique(trans_R[!is.na(trans_R)]), collapse = "|"), "R", x, ignore.case = TRUE)
x <- gsub(paste0(unique(trans_S[!is.na(trans_S)]), collapse = "|"), "S", x, ignore.case = TRUE)
x <- gsub(paste0(unique(trans_I[!is.na(trans_I)]), collapse = "|"), "I", x, ignore.case = TRUE)
# replace all English textual input
x <- gsub("res(is(tant)?)?", "R", x, ignore.case = TRUE)
x <- gsub("sus(cep(tible)?)?", "S", x, ignore.case = TRUE)
x <- gsub("int(er(mediate)?)?", "I", x, ignore.case = TRUE)
x <- gsub("inc(r(eased)?)? exp[a-z]*", "I", x, ignore.case = TRUE)
x[x %like% "([^a-z]|^)res(is(tant)?)?"] <- "R"
x[x %like% "([^a-z]|^)sus(cep(tible)?)?"] <- "S"
x[x %like% "([^a-z]|^)int(er(mediate)?)?|incr.*exp"] <- "I"
# remove all spaces
x <- gsub(" +", "", x)
# remove all MIC-like values: numbers, operators and periods
@ -776,7 +775,6 @@ exec_as.rsi <- function(method, @@ -776,7 +775,6 @@ exec_as.rsi <- function(method,
if (guideline_coerced != guideline) {
if (message_not_thrown_before("as.rsi")) {
message_("Using guideline ", font_bold(guideline_coerced), " as input for `guideline`.")
remember_thrown_message("as.rsi")
}
}
@ -815,7 +813,6 @@ exec_as.rsi <- function(method, @@ -815,7 +813,6 @@ exec_as.rsi <- function(method,
if (guideline_coerced %unlike% "EUCAST") {
if (message_not_thrown_before("as.rsi2")) {
warning_("Using 'add_intrinsic_resistance' is only useful when using EUCAST guidelines, since the rules for intrinsic resistance are based on EUCAST.", call = FALSE)
remember_thrown_message("as.rsi2")
}
} else {
new_rsi[i] <- "R"
@ -880,7 +877,6 @@ exec_as.rsi <- function(method, @@ -880,7 +877,6 @@ exec_as.rsi <- function(method,
message_("WARNING.", add_fn = list(font_yellow, font_bold), as_note = FALSE)
if (message_not_thrown_before("as.rsi3")) {
warning_("Found intrinsic resistance in some bug/drug combinations, although it was not applied.\nUse `as.rsi(..., add_intrinsic_resistance = TRUE)` to apply it.", call = FALSE)
remember_thrown_message("as.rsi3")
}
warned <- TRUE
}

1
R/rsi_calc.R

@ -152,7 +152,6 @@ rsi_calc <- function(..., @@ -152,7 +152,6 @@ rsi_calc <- function(...,
" your_data %>% mutate_if(is.rsi.eligible, as.rsi)\n",
" your_data %>% mutate(across(where(is.rsi.eligible), as.rsi))",
call = FALSE)
remember_thrown_message("rsi_calc")
}
}

BIN
R/sysdata.rda

Binary file not shown.

74
R/vctrs.R

@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
# ==================================================================== #
# TITLE #
# Antimicrobial Resistance (AMR) Data Analysis for R #
# #
# SOURCE #
# https://github.com/msberends/AMR #
# #
# LICENCE #
# (c) 2018-2021 Berends MS, Luz CF et al. #
# Developed at the University of Groningen, the Netherlands, in #
# collaboration with non-profit organisations Certe Medical #
# Diagnostics & Advice, and University Medical Center Groningen. #
# #
# This R package is free software; you can freely use and distribute #
# it for both personal and commercial purposes under the terms of the #
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
# the Free Software Foundation. #
# We created this package for both routine data analysis and academic #
# research and it was publicly released in the hope that it will be #
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
# #
# Visit our website for the full manual and a complete tutorial about #
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
# These are all S3 implementations for the vctrs package,
# that is used internally by tidyverse packages such as dplyr.
# They are to convert AMR-specific classes to bare characters and integers.
# All of them will be exported using s3_register() in R/zzz.R when loading the package.
# S3: ab
vec_ptype2.character.ab <- function(x, y, ...) {
x
}
vec_ptype2.ab.character <- function(x, y, ...) {
y
}
vec_cast.character.ab <- function(x, to, ...) {
unclass(x)
}
# S3: mo
vec_ptype2.character.mo <- function(x, y, ...) {
x
}
vec_ptype2.mo.character <- function(x, y, ...) {
y
}
vec_cast.character.mo <- function(x, to, ...) {
unclass(x)
}
# S3: disk
vec_ptype2.integer.disk <- function(x, y, ...) {
x
}
vec_ptype2.disk.integer <- function(x, y, ...) {
y
}
vec_cast.integer.disk <- function(x, to, ...) {
unclass(x)
}
# S3: ab_selector
# see https://github.com/tidyverse/dplyr/issues/5955 why this is required
vec_ptype2.character.ab_selector <- function(x, y, ...) {
x
}
vec_ptype2.ab_selector.character <- function(x, y, ...) {
y
}
vec_cast.character.ab_selector <- function(x, to, ...) {
unclass(x)
}

17
R/zzz.R

@ -56,15 +56,29 @@ if (utf8_supported && !is_latex) { @@ -56,15 +56,29 @@ if (utf8_supported && !is_latex) {
# 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
# Support for 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")
# Support for autoplot() from the ggplot2 package
s3_register("ggplot2::autoplot", "rsi")
s3_register("ggplot2::autoplot", "mic")
s3_register("ggplot2::autoplot", "disk")
s3_register("ggplot2::autoplot", "resistance_predict")
# Support vctrs package for use in e.g. dplyr verbs
s3_register("vctrs::vec_ptype2", "ab.character")
s3_register("vctrs::vec_ptype2", "character.ab")
s3_register("vctrs::vec_cast", "character.ab")
s3_register("vctrs::vec_ptype2", "mo.character")
s3_register("vctrs::vec_ptype2", "character.mo")
s3_register("vctrs::vec_cast", "character.mo")
s3_register("vctrs::vec_ptype2", "ab_selector.character")
s3_register("vctrs::vec_ptype2", "character.ab_selector")
s3_register("vctrs::vec_cast", "character.ab_selector")
s3_register("vctrs::vec_ptype2", "disk.integer")
s3_register("vctrs::vec_ptype2", "integer.disk")
s3_register("vctrs::vec_cast", "integer.disk")
# if mo source exists, fire it up (see mo_source())
try({
@ -75,6 +89,7 @@ if (utf8_supported && !is_latex) { @@ -75,6 +89,7 @@ if (utf8_supported && !is_latex) {
# reference data - they have additional columns compared to `antibiotics` and `microorganisms` to improve speed
# they can't be part of R/sysdata.rda since CRAN thinks it would make the package too large (+3 MB)
assign(x = "AB_lookup", value = create_AB_lookup(), envir = asNamespace("AMR"))
assign(x = "MO_lookup", value = create_MO_lookup(), envir = asNamespace("AMR"))
assign(x = "MO.old_lookup", value = create_MO.old_lookup(), envir = asNamespace("AMR"))

1
_pkgdown.yml

@ -32,6 +32,7 @@ development: @@ -32,6 +32,7 @@ development:
news:
one_page: true
cran_dates: true
navbar:
title: "AMR (for R)"

BIN
data-raw/AMR_latest.tar.gz

Binary file not shown.

4
data-raw/translations.tsv

@ -32,8 +32,10 @@ vegetative TRUE TRUE FALSE FALSE vegetativ vegetatief vegetativo vegetativo vég @@ -32,8 +32,10 @@ vegetative TRUE TRUE FALSE FALSE vegetativ vegetatief vegetativo vegetativo vég
([([ ]*?)Group TRUE TRUE FALSE FALSE \\1Gruppe \\1Groep \\1Grupo \\1Gruppo \\1Groupe \\1Grupo
no .*growth TRUE FALSE FALSE FALSE keine? .*wachstum geen .*groei no .*crecimientonon sem .*crescimento pas .*croissance sem .*crescimento
no|not TRUE FALSE FALSE FALSE keine? geen|niet no|sin sem non sem
Susceptible TRUE FALSE FALSE FALSE Empfindlich Gevoelig Susceptible
Intermediate TRUE FALSE FALSE FALSE Mittlere Intermediair Intermedio
Susceptible, incr. exp. FALSE TRUE FALSE FALSE Empfindlich, erh Belastung Gevoelig, hoge dosis
susceptible, incr. exp. FALSE TRUE FALSE FALSE empfindlich, erh Belastung gevoelig, hoge dosis
Susceptible TRUE FALSE FALSE FALSE Empfindlich Gevoelig Susceptible
Incr. exposure TRUE FALSE FALSE FALSE Empfindlich, erh Belastung 'Incr. exposure' 'Incr. exposure'
Resistant TRUE FALSE FALSE FALSE Resistent Resistent Resistente
antibiotic TRUE TRUE FALSE FALSE Antibiotikum antibioticum antibiótico

1 pattern regular_expr case_sensitive affect_ab_name affect_mo_name de nl es it fr pt
32 ([([ ]*?)Group TRUE TRUE FALSE FALSE \\1Gruppe \\1Groep \\1Grupo \\1Gruppo \\1Groupe \\1Grupo
33 no .*growth TRUE FALSE FALSE FALSE keine? .*wachstum geen .*groei no .*crecimientonon sem .*crescimento pas .*croissance sem .*crescimento
34 no|not TRUE FALSE FALSE FALSE keine? geen|niet no|sin sem non sem
Susceptible TRUE FALSE FALSE FALSE Empfindlich Gevoelig Susceptible
35 Intermediate TRUE FALSE FALSE FALSE Mittlere Intermediair Intermedio
36 Susceptible, incr. exp. FALSE TRUE FALSE FALSE Empfindlich, erh Belastung Gevoelig, hoge dosis
37 susceptible, incr. exp. FALSE TRUE FALSE FALSE empfindlich, erh Belastung gevoelig, hoge dosis
38 Susceptible TRUE FALSE FALSE FALSE Empfindlich Gevoelig Susceptible
39 Incr. exposure TRUE FALSE FALSE FALSE Empfindlich, erh Belastung 'Incr. exposure' 'Incr. exposure'
40 Resistant TRUE FALSE FALSE FALSE Resistent Resistent Resistente
41 antibiotic TRUE TRUE FALSE FALSE Antibiotikum antibioticum antibiótico

167
docs/404.html

@ -1,76 +1,35 @@ @@ -1,76 +1,35 @@
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page not found (404) • AMR (for R)</title>
<!-- favicons -->
<link rel="icon" type="image/png" sizes="16x16" href="https://msberends.github.io/AMR//favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://msberends.github.io/AMR//favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="https://msberends.github.io/AMR//apple-touch-icon.png" />
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="https://msberends.github.io/AMR//apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="https://msberends.github.io/AMR//apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="https://msberends.github.io/AMR//apple-touch-icon-60x60.png" />
<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script>
<!-- bootstrap-toc -->
<link rel="stylesheet" href="https://msberends.github.io/AMR//bootstrap-toc.css">
<script src="https://msberends.github.io/AMR//bootstrap-toc.js"></script>
<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" />
<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script>
<!-- headroom.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>
<!-- pkgdown -->
<link href="https://msberends.github.io/AMR//pkgdown.css" rel="stylesheet">
<script src="https://msberends.github.io/AMR//pkgdown.js"></script>
<link href="https://msberends.github.io/AMR//extra.css" rel="stylesheet">
<script src="https://msberends.github.io/AMR//extra.js"></script>
<meta property="og:title" content="Page not found (404)" />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
<!--[if lt IE 9]>
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="https://msberends.github.io/AMR/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://msberends.github.io/AMR/favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="https://msberends.github.io/AMR/apple-touch-icon.png">
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="https://msberends.github.io/AMR/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="https://msberends.github.io/AMR/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="https://msberends.github.io/AMR/apple-touch-icon-60x60.png">
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="https://msberends.github.io/AMR/bootstrap-toc.css">
<script src="https://msberends.github.io/AMR/bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="https://msberends.github.io/AMR/pkgdown.css" rel="stylesheet">
<script src="https://msberends.github.io/AMR/pkgdown.js"></script><link href="https://msberends.github.io/AMR/extra.css" rel="stylesheet">
<script src="https://msberends.github.io/AMR/extra.js"></script><meta property="og:title" content="Page not found (404)">
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body data-spy="scroll" data-target="#toc">
</head>
<body data-spy="scroll" data-target="#toc">
<div class="container template-title-body">
<header>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
@ -80,22 +39,22 @@ @@ -80,22 +39,22 @@
<span class="icon-bar"></span>
</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.7.1.9021</span>
<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.7.1.9022</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.html">
<li>
<a href="https://msberends.github.io/AMR/index.html">
<span class="fa fa-home"></span>
Home
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<a href="https://msberends.github.io/AMR/#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="fa fa-question-circle"></span>
How to
@ -103,78 +62,78 @@ @@ -103,78 +62,78 @@
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="articles/AMR.html">
<li>
<a href="https://msberends.github.io/AMR/articles/AMR.html">
<span class="fa fa-directions"></span>
Conduct AMR analysis
</a>
</li>
<li>
<a href="articles/resistance_predict.html">
<a href="https://msberends.github.io/AMR/articles/resistance_predict.html">
<span class="fa fa-dice"></span>
Predict antimicrobial resistance
</a>
</li>
<li>
<a href="articles/datasets.html">
<a href="https://msberends.github.io/AMR/articles/datasets.html">
<span class="fa fa-database"></span>
Data sets for download / own use
</a>
</li>
<li>
<a href="articles/PCA.html">
<a href="https://msberends.github.io/AMR/articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct principal component analysis for AMR
</a>
</li>
<li>
<a href="articles/MDR.html">
<a href="https://msberends.github.io/AMR/articles/MDR.html">
<span class="fa fa-skull-crossbones"></span>
Determine multi-drug resistance (MDR)
</a>
</li>
<li>
<a href="articles/WHONET.html">
<a href="https://msberends.github.io/AMR/articles/WHONET.html">
<span class="fa fa-globe-americas"></span>
Work with WHONET data
</a>
</li>
<li>
<a href="articles/SPSS.html">
<a href="https://msberends.github.io/AMR/articles/SPSS.html">
<span class="fa fa-file-upload"></span>
Import data from SPSS/SAS/Stata
</a>
</li>
<li>
<a href="articles/EUCAST.html">
<a href="https://msberends.github.io/AMR/articles/EUCAST.html">
<span class="fa fa-exchange-alt"></span>
Apply EUCAST rules
</a>
</li>
<li>
<a href="reference/mo_property.html">
<a href="https://msberends.github.io/AMR/reference/mo_property.html">
<span class="fa fa-bug"></span>
Get properties of a microorganism
</a>
</li>
<li>
<a href="reference/ab_property.html">
<a href="https://msberends.github.io/AMR/reference/ab_property.html">
<span class="fa fa-capsules"></span>
Get properties of an antibiotic
</a>
</li>
<li>
<a href="articles/benchmarks.html">
<a href="https://msberends.github.io/AMR/articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
Other: benchmarks
@ -183,29 +142,29 @@ @@ -183,29 +142,29 @@
</ul>
</li>
<li>
<a href="reference/index.html">
<a href="https://msberends.github.io/AMR/reference/index.html">
<span class="fa fa-book-open"></span>
Manual
</a>
</li>
<li>
<a href="authors.html">
<a href="https://msberends.github.io/AMR/authors.html">
<span class="fa fa-users"></span>
Authors
</a>
</li>
<li>
<a href="news/index.html">
<a href="https://msberends.github.io/AMR/news/index.html">
<span class="far fa-newspaper"></span>
Changelog
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/msberends/AMR">
<span class="fab fa-github"></span>
@ -213,23 +172,23 @@ @@ -213,23 +172,23 @@
</