mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 00:02:38 +02:00
(v0.7.1.9056) mo and ab subsetting
This commit is contained in:
38
R/ab.R
38
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
|
||||
|
@ -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) %>%
|
||||
|
@ -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
|
||||
|
38
R/mo.R
38
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
|
||||
|
Reference in New Issue
Block a user