diff --git a/DESCRIPTION b/DESCRIPTION index 9f14e5f7..7d5f5ad4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 0.7.0.9002 +Version: 0.7.0.9003 Date: 2019-06-08 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NAMESPACE b/NAMESPACE index 242c7b98..4983e269 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -173,6 +173,8 @@ export(resistance_predict) export(right_join_microorganisms) export(rsi_predict) export(scale_rsi_colours) +export(scale_type.ab) +export(scale_type.mo) export(scale_y_percent) export(semi_join_microorganisms) export(set_mo_source) diff --git a/NEWS.md b/NEWS.md index e030853c..f0dcc7c0 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 0.7.0.9002 +# AMR 0.7.0.9003 #### New * Support for all scientifically published pathotypes of *E. coli* to date. Supported are: AIEC (Adherent-Invasive *E. coli*), ATEC (Atypical Entero-pathogenic *E. coli*), DAEC (Diffusely Adhering *E. coli*), EAEC (Entero-Aggresive *E. coli*), EHEC (Entero-Haemorrhagic *E. coli*), EIEC (Entero-Invasive *E. coli*), EPEC (Entero-Pathogenic *E. coli*), ETEC (Entero-Toxigenic *E. coli*), NMEC (Neonatal Meningitis‐causing *E. coli*), STEC (Shiga-toxin producing *E. coli*) and UPEC (Uropathogenic *E. coli*). All these lead to the microbial ID of *E. coli*: @@ -12,7 +12,7 @@ #### Changed * Fixed bug in translation of microorganism names * Fixed bug in determining taxonomic kingdoms -* Algorithm improvements for `as.ab()` and `as.mo()` to understand even more severe misspelled input +* Algorithm improvements for `as.ab()` and `as.mo()` to understand even more severely misspelled input * Added `ggplot2` methods for automatically determining the scale type of classes `mo` and `ab` * Added names of object in the header in frequency tables, even when using pipes * Prevented `"bacteria"` from getting coerced by `as.ab()` because Bacterial is a brand name of trimethoprim (TMP) diff --git a/R/ab.R b/R/ab.R index da87971c..0b1b0565 100755 --- a/R/ab.R +++ b/R/ab.R @@ -258,12 +258,3 @@ as.data.frame.ab <- function (x, ...) { pull.ab <- function(.data, ...) { pull(as.data.frame(.data), ...) } - -#' @exportMethod scale_type.ab -#' @noRd -scale_type.ab <- function(x) { - # fix for: - # "Don't know how to automatically pick scale for object of type ab. Defaulting to continuous." - # "Error: Discrete value supplied to continuous scale" - "discrete" -} diff --git a/R/extended.R b/R/extended.R new file mode 100644 index 00000000..bb94623e --- /dev/null +++ b/R/extended.R @@ -0,0 +1,48 @@ +# ==================================================================== # +# TITLE # +# Antimicrobial Resistance (AMR) Analysis # +# # +# SOURCE # +# https://gitlab.com/msberends/AMR # +# # +# LICENCE # +# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) # +# # +# 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. # +# # +# This R package was created for academic research and was publicly # +# released in the hope that it will be useful, but it comes WITHOUT # +# ANY WARRANTY OR LIABILITY. # +# Visit our website for more info: https://msberends.gitlab.io/AMR. # +# ==================================================================== # + +#' Extended functions +#' +#' These functions are extensions of functions in other packages. +#' @inheritSection AMR Read more on our website! +#' @export +#' @keywords internal +#' @name extended-functions +#' @rdname extended-functions +#' @exportMethod scale_type.mo +#' @export +scale_type.mo <- function(x) { + # fix for: + # "Don't know how to automatically pick scale for object of type mo. Defaulting to continuous." + # "Error: Discrete value supplied to continuous scale" + "discrete" +} + +#' @rdname extended-functions +#' @exportMethod scale_type.ab +#' @export +scale_type.ab <- function(x) { + # fix for: + # "Don't know how to automatically pick scale for object of type mo. Defaulting to continuous." + # "Error: Discrete value supplied to continuous scale" + "discrete" +} + diff --git a/R/mo.R b/R/mo.R index 257553b7..f87b7564 100755 --- a/R/mo.R +++ b/R/mo.R @@ -1484,13 +1484,3 @@ translate_allow_uncertain <- function(allow_uncertain) { } allow_uncertain } - -#' @exportMethod scale_type.mo -# @export -#' @noRd -scale_type.mo <- function(x) { - # fix for: - # "Don't know how to automatically pick scale for object of type mo. Defaulting to continuous." - # "Error: Discrete value supplied to continuous scale" - "discrete" -} diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index ee9bb86d..fcea131b 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@ AMR (for R) - 0.7.0.9002 + 0.7.0.9003 diff --git a/docs/articles/index.html b/docs/articles/index.html index 0474bab8..bdfda45d 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -78,7 +78,7 @@ AMR (for R) - 0.7.0.9002 + 0.7.0.9003 diff --git a/docs/authors.html b/docs/authors.html index 01989d69..e36fa274 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -78,7 +78,7 @@ AMR (for R) - 0.7.0.9002 + 0.7.0.9003 diff --git a/docs/index.html b/docs/index.html index 5f2a49a5..6d5dc0e9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 0.7.0.9002 + 0.7.0.9003 diff --git a/docs/news/index.html b/docs/news/index.html index 84ed896c..cb18f148 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -78,7 +78,7 @@ AMR (for R) - 0.7.0.9002 + 0.7.0.9003 @@ -239,9 +239,9 @@ -
+

-AMR 0.7.0.9002 Unreleased +AMR 0.7.0.9003 Unreleased

@@ -262,7 +262,7 @@

diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 4576c0a5..9d039f3b 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -63,6 +63,9 @@ https://msberends.gitlab.io/AMR/reference/eucast_rules.html + + https://msberends.gitlab.io/AMR/reference/extended-functions.html + https://msberends.gitlab.io/AMR/reference/filter_ab_class.html diff --git a/man/extended-functions.Rd b/man/extended-functions.Rd new file mode 100644 index 00000000..a3966eea --- /dev/null +++ b/man/extended-functions.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/extended.R +\name{extended-functions} +\alias{extended-functions} +\alias{scale_type.mo} +\alias{scale_type.ab} +\title{Extended functions} +\usage{ +scale_type.mo(x) + +scale_type.ab(x) +} +\description{ +These functions are extensions of functions in other packages. +} +\section{Read more on our website!}{ + +On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. +} + +\keyword{internal} diff --git a/tests/testthat/test-ggplot_rsi.R b/tests/testthat/test-ggplot_rsi.R index 979d5f31..ce5a8a9e 100644 --- a/tests/testthat/test-ggplot_rsi.R +++ b/tests/testthat/test-ggplot_rsi.R @@ -62,4 +62,16 @@ test_that("ggplot_rsi works", { expect_error(ggplot_rsi(septic_patients, fun = "invalid")) expect_error(geom_rsi(septic_patients, fun = "invalid")) + # support for scale_type ab and mo + expect_equal(class((data.frame(mo = as.mo(c("e. coli", "s aureus")), + n = c(40, 100)) %>% + ggplot(aes(x = mo, y = n)) + + geom_col())$data), + "data.frame") + expect_equal(class((data.frame(ab = as.ab(c("amx", "amc")), + n = c(40, 100)) %>% + ggplot(aes(x = ab, y = n)) + + geom_col())$data), + "data.frame") + })