diff --git a/NAMESPACE b/NAMESPACE index b877b14..7e6be49 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +S3method(summarize_rtestimate,Rt) S3method(summarize_rtestimate,cv_poisson_rt) S3method(summarize_rtestimate,default) S3method(summarize_rtestimate,epinow) diff --git a/R/summarize_rtestimate.R b/R/summarize_rtestimate.R index 012cbcd..18a8d13 100644 --- a/R/summarize_rtestimate.R +++ b/R/summarize_rtestimate.R @@ -1,14 +1,13 @@ - #' Create a new summary object -#' +#' #' Creates a new summary object for the `summrt` package while validating the input. -#' +#' #' @param date Integer vector. vector of index dates. #' @param median Double vector. vector of median values. #' @param lb Double vector. vector of lower bounds. #' @param ub Double vector. vector of upper bounds. #' @param package String. Name of the package. -#' @export +#' @export #' @return A list of class `summrt_summary`. with the following components: #' - `date`: Integer vector. vector of index dates. #' - `median`: Double vector. vector of median values. @@ -115,12 +114,11 @@ summarize_rtestimate.epinow <- function(x, level = 0.95, ...) { if (!requireNamespace("EpiNow2", quietly = TRUE)) { cli::cli_abort("You must install the {.pkg EpiNow2} package for this functionality.") } - checkmate::assert_number(level, lower = 0, upper = 1) # res <- x$estimates$summarized |> dplyr::select() } -#' @export +#' @export #' @details The `estimate_R` method is for the `EpiEstim` package. #' @rdname summarize_rtestimate summarize_rtestimate.estimate_R <- function(x, ...) { @@ -128,7 +126,7 @@ summarize_rtestimate.estimate_R <- function(x, ...) { if (!requireNamespace("EpiEstim", quietly = TRUE)) { cli::cli_abort("You must install the {.pkg EpiEstim} package for this functionality.") } - + new_summarize( date = x$R$t_end, median = x$R$`Median(R)`, @@ -136,4 +134,21 @@ summarize_rtestimate.estimate_R <- function(x, ...) { ub = x$R$`Quantile.0.975(R)`, package = "EpiEstim" ) -} \ No newline at end of file +} + +#' @export +#' @details The `Rt` method is for the `EpiLPS` package. +#' @rdname summarize_rtestimate +summarize_rtestimate.Rt <- function(x, ...) { + if (!requireNamespace("EpiLPS", quietly = TRUE)) { + cli::cli_abort("You must install the {.pkg EpiLPS} package for this functionality.") + } + + new_summarize( + date = x$RLPS$Time, + median = x$RLPS$Rq0.50, + lb = x$RLPS$Rq0.025, + ub = x$RLPS$Rq0.975, + package = "EpiLPS" + ) +} diff --git a/man/summarize_rtestimate.Rd b/man/summarize_rtestimate.Rd index 4f20a48..4777a6d 100644 --- a/man/summarize_rtestimate.Rd +++ b/man/summarize_rtestimate.Rd @@ -7,6 +7,7 @@ \alias{summarize_rtestimate.poisson_rt} \alias{summarize_rtestimate.epinow} \alias{summarize_rtestimate.estimate_R} +\alias{summarize_rtestimate.Rt} \title{Extract Rt estimation from a model fit} \usage{ summarize_rtestimate(x, ...) @@ -20,6 +21,8 @@ summarize_rtestimate(x, ...) \method{summarize_rtestimate}{epinow}(x, level = 0.95, ...) \method{summarize_rtestimate}{estimate_R}(x, ...) + +\method{summarize_rtestimate}{Rt}(x, ...) } \arguments{ \item{x}{Object to extract Rt from.} @@ -35,4 +38,6 @@ Extract Rt estimation from a model fit } \details{ The \code{estimate_R} method is for the \code{EpiEstim} package. + +The \code{Rt} method is for the \code{EpiLPS} package. }