diff --git a/DESCRIPTION b/DESCRIPTION index 117b5e2a..f5e0783c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 0.7.1.9055 -Date: 2019-08-13 +Version: 0.7.1.9056 +Date: 2019-08-14 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), @@ -11,6 +11,8 @@ Authors@R: c( family = "Friedrich", given = c("Alex", "W."), email = "alex.friedrich@umcg.nl", comment = c(ORCID = "0000-0003-4881-038X")), person(role = c("aut", "ths"), family = "Sinha", given = c("Bhanu", "N.", "M."), email = "b.sinha@umcg.nl", comment = c(ORCID = "0000-0003-1634-0010")), + person(role = c("aut", "ths"), + family = "Albers", given = c("Casper", "J."), email = "c.j.albers@rug.nl", comment = c(ORCID = "0000-0002-9213-6743")), person(role = c("aut", "ths"), family = "Glasner", given = "Corinna", email = "c.glasner@umcg.nl", comment = c(ORCID = "0000-0003-1241-1328")), person(role = "ctb", diff --git a/NAMESPACE b/NAMESPACE index 7cafc1af..5c9db6c2 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,12 @@ S3method("[",ab) S3method("[",mo) +S3method("[<-",ab) +S3method("[<-",mo) +S3method("[[",ab) +S3method("[[",mo) +S3method("[[<-",ab) +S3method("[[<-",mo) S3method(as.data.frame,ab) S3method(as.data.frame,mo) S3method(as.double,mic) @@ -13,6 +19,8 @@ S3method(as.rsi,disk) S3method(as.rsi,mic) S3method(barplot,mic) S3method(barplot,rsi) +S3method(c,ab) +S3method(c,mo) S3method(droplevels,mic) S3method(droplevels,rsi) S3method(freq,mo) @@ -172,6 +180,12 @@ export(skewness) export(theme_rsi) exportMethods("[.ab") exportMethods("[.mo") +exportMethods("[<-.ab") +exportMethods("[<-.mo") +exportMethods("[[.ab") +exportMethods("[[.mo") +exportMethods("[[<-.ab") +exportMethods("[[<-.mo") exportMethods(as.data.frame.ab) exportMethods(as.data.frame.mo) exportMethods(as.double.mic) @@ -179,6 +193,8 @@ exportMethods(as.integer.mic) exportMethods(as.numeric.mic) exportMethods(barplot.mic) exportMethods(barplot.rsi) +exportMethods(c.ab) +exportMethods(c.mo) exportMethods(droplevels.mic) exportMethods(droplevels.rsi) exportMethods(freq.mo) diff --git a/NEWS.md b/NEWS.md index d84c3818..7a95044b 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 0.7.1.9055 +# AMR 0.7.1.9056 ### Breaking * Function `freq()` has moved to a new package, [`clean`](https://github.com/msberends/clean) ([CRAN link](https://cran.r-project.org/package=clean)). Creating frequency tables is actually not the scope of this package (never was) and this function has matured a lot over the last two years. Therefore, a new package was created for data cleaning and checking and it perfectly fits the `freq()` function. The [`clean`](https://github.com/msberends/clean) package is available on CRAN and will be installed automatically when updating the `AMR` package, that now imports it. In a later stage, the `skewness()` and `kurtosis()` functions will be moved to the `clean` package too. @@ -73,7 +73,7 @@ * Classes `ab` and `mo` will now be preserved in any subsetting #### Other -* Added Dr Bart Meijer, Dr Dennis Souverein and Annick Lenglet as contributors +* Added Prof Dr Casper Albers as doctoral advisor and Dr Bart Meijer, Dr Dennis Souverein and Annick Lenglet as contributors # AMR 0.7.1 diff --git a/R/ab.R b/R/ab.R index 19864eb3..ecac120d 100755 --- a/R/ab.R +++ b/R/ab.R @@ -282,10 +282,42 @@ as.data.frame.ab <- function (x, ...) { #' @exportMethod [.ab #' @export #' @noRd -"[.ab" <- function (x, ...) { - # this function is needed to preserve the "ab" class for any subsetting, like df %>% filter(...) +"[.ab" <- function(x, ...) { y <- NextMethod() - structure(y, class = "ab") + attributes(y) <- attributes(x) + y +} +#' @exportMethod [<-.ab +#' @export +#' @noRd +"[<-.ab" <- function(value) { + y <- NextMethod() + attributes(y) <- attributes(value) + y +} +#' @exportMethod [[.ab +#' @export +#' @noRd +"[[.ab" <- function(x, ...) { + y <- NextMethod() + attributes(y) <- attributes(x) + y +} +#' @exportMethod [[<-.ab +#' @export +#' @noRd +"[[<-.ab" <- function(i, j, ..., value) { + y <- NextMethod() + attributes(y) <- attributes(value) + y +} +#' @exportMethod c.ab +#' @export +#' @noRd +c.ab <- function(x, ...) { + y <- NextMethod() + attributes(y) <- attributes(x) + y } #' @importFrom pillar type_sum diff --git a/R/first_isolate.R b/R/first_isolate.R index f9abcd15..50baae75 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -79,8 +79,8 @@ #' @source Methodology of this function is based on: \strong{M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition}, 2014, \emph{Clinical and Laboratory Standards Institute (CLSI)}. \url{https://clsi.org/standards/products/microbiology/documents/m39/}. #' @inheritSection AMR Read more on our website! #' @examples -#' # septic_patients is a dataset available in the AMR package. It is true, genuine data. -#' ?septic_patients +#' # `septic_patients` is a dataset available in the AMR package. It is true, genuine data. +#' # See ?septic_patients. #' #' library(dplyr) #' # Filter on first isolates: @@ -97,7 +97,7 @@ #' # or for first weighted isolates: #' septic_patients %>% #' filter_first_weighted_isolate() -#' +#' #' # Now let's see if first isolates matter: #' A <- septic_patients %>% #' group_by(hospital_id) %>% diff --git a/R/key_antibiotics.R b/R/key_antibiotics.R index 807f729d..f802492f 100755 --- a/R/key_antibiotics.R +++ b/R/key_antibiotics.R @@ -48,8 +48,8 @@ #' @seealso \code{\link{first_isolate}} #' @inheritSection AMR Read more on our website! #' @examples -#' # septic_patients is a dataset available in the AMR package -#' ?septic_patients +#' # `septic_patients` is a dataset available in the AMR package. It is true, genuine data. +#' # See ?septic_patients. #' #' library(dplyr) #' # set key antibiotics to a new variable diff --git a/R/mo.R b/R/mo.R index db163435..27078825 100755 --- a/R/mo.R +++ b/R/mo.R @@ -1723,10 +1723,42 @@ as.data.frame.mo <- function(x, ...) { #' @exportMethod [.mo #' @export #' @noRd -"[.mo" <- function (x, ...) { - # this function is needed to preserve the "mo" class for any subsetting, like df %>% filter(...) +"[.mo" <- function(x, ...) { y <- NextMethod() - to_class_mo(y) + attributes(y) <- attributes(x) + y +} +#' @exportMethod [<-.mo +#' @export +#' @noRd +"[<-.mo" <- function(i, j, ..., value) { + y <- NextMethod() + attributes(y) <- attributes(value) + y +} +#' @exportMethod [[.mo +#' @export +#' @noRd +"[[.mo" <- function(x, ...) { + y <- NextMethod() + attributes(y) <- attributes(x) + y +} +#' @exportMethod [[<-.mo +#' @export +#' @noRd +"[[<-.mo" <- function(value) { + y <- NextMethod() + attributes(y) <- attributes(value) + y +} +#' @exportMethod c.mo +#' @export +#' @noRd +c.mo <- function(x, ...) { + y <- NextMethod() + attributes(y) <- attributes(x) + y } #' @rdname as.mo diff --git a/_pkgdown.yml b/_pkgdown.yml index b230db94..fbeee742 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -172,12 +172,14 @@ authors: href: https://www.rug.nl/staff/m.s.berends/ Christian F. Luz: href: https://www.rug.nl/staff/c.f.luz/ - Corinna Glasner: - href: https://www.rug.nl/staff/c.glasner/ Alex W. Friedrich: href: https://www.rug.nl/staff/a.w.friedrich/ Bhanu N. M. Sinha: href: https://www.rug.nl/staff/b.sinha/ + Casper J. Albers: + href: https://www.rug.nl/staff/c.j.albers/ + Corinna Glasner: + href: https://www.rug.nl/staff/c.glasner/ template: assets: "pkgdown/logos" # use logos in this folder diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index ae2885e7..99df50d3 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@ AMR (for R) - 0.7.1.9055 + 0.7.1.9056 @@ -513,7 +513,7 @@ END OF TERMS AND CONDITIONS