diff --git a/DESCRIPTION b/DESCRIPTION index ec415e0..9af7694 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,6 +9,7 @@ Encoding: UTF-8 LazyData: true Suggests: testthat, vdiffr, roxygen2, knitr, rmarkdown, outbreaks, magrittr Imports: stats, utils, incidence, distcrete, ggplot2 -RoxygenNote: 6.0.1 +RoxygenNote: 6.1.0 +Remotes: reconhub/incidence URL: http://www.repidemicsconsortium.org/projections BugReports: http://github.com/reconhub/projections/issues diff --git a/NAMESPACE b/NAMESPACE index 4e82da5..b7e6de4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,7 +4,6 @@ S3method("[",projections) S3method(as.data.frame,projections) S3method(as.matrix,projections) S3method(cumulate,projections) -S3method(get_dates,default) S3method(get_dates,projections) S3method(plot,projections) S3method(print,projections) @@ -15,4 +14,5 @@ export(get_dates) export(project) importFrom(graphics,plot) importFrom(incidence,cumulate) +importFrom(incidence,get_dates) importFrom(stats,as.ts) diff --git a/NEWS.md b/NEWS.md index 2020682..d0452d0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# projections 0.3.1 + + - `get_dates()` now inherits the generic `get_dates()` from incidence + # projections 0.3.0 ## New features diff --git a/R/accessors.R b/R/accessors.R index e464b57..56bfcb9 100644 --- a/R/accessors.R +++ b/R/accessors.R @@ -7,12 +7,11 @@ #' \item \code{get_dates}: get dates of the predictions. #' #' } -#' +#' @name get_dates #' @rdname projections_accessors #' #' @author Thibaut Jombart \email{thibautjombart@@gmail.com} #' -#' @export #' #' @param x A \code{projections} object. #' @@ -21,7 +20,7 @@ #' @examples #' #' -#' if (require(distcrete) && require(incidence)) { +#' if (require(distcrete) && require(incidence)) { withAutoprint({ #' #' ## prepare input: epicurve and serial interval #' dat <- c(0, 2, 2, 3, 3, 5, 5, 5, 6, 6, 6, 6) @@ -40,28 +39,12 @@ #' get_dates(pred_1) #' max(i$dates) # predictions start 1 day after last incidence #' -#' } -#' - -get_dates <- function(x, ...) { - UseMethod("get_dates", x) -} - - -#' @rdname projections_accessors -#' @export -#' @aliases get_dates.default - -get_dates.default <- function(x, ...) { - stop(sprintf("Not implemented for class %s", - paste(class(x), collapse = ", "))) -} - - -#' @rdname projections_accessors -#' @export +#' })} #' @aliases get_dates.projections - +#' @aliases get_dates +#' @importFrom incidence get_dates +#' @export get_dates +#' @export get_dates.projections <- function(x, ...) { attr(x, "dates") } diff --git a/man/plot.projections.Rd b/man/plot.projections.Rd index 4f6f14b..28f7b98 100644 --- a/man/plot.projections.Rd +++ b/man/plot.projections.Rd @@ -7,11 +7,11 @@ \usage{ \method{plot}{projections}(x, ...) -add_projections(p, x, quantiles = c(0.01, 0.05, 0.1, 0.5), ribbon = TRUE, - boxplots = FALSE, palette = quantile_pal, quantiles_alpha = 1, - linetype = 1, linesize = 0.5, ribbon_quantiles = NULL, - ribbon_color = NULL, ribbon_alpha = 0.3, boxplots_color = "#47476b", - boxplots_alpha = 0.8, outliers = TRUE) +add_projections(p, x, quantiles = c(0.01, 0.05, 0.1, 0.5), + ribbon = TRUE, boxplots = FALSE, palette = quantile_pal, + quantiles_alpha = 1, linetype = 1, linesize = 0.5, + ribbon_quantiles = NULL, ribbon_color = NULL, ribbon_alpha = 0.3, + boxplots_color = "#47476b", boxplots_alpha = 0.8, outliers = TRUE) } \arguments{ \item{x}{A \code{projections} object.} diff --git a/man/projections_accessors.Rd b/man/projections_accessors.Rd index 878fe02..3717803 100644 --- a/man/projections_accessors.Rd +++ b/man/projections_accessors.Rd @@ -2,14 +2,9 @@ % Please edit documentation in R/accessors.R \name{get_dates} \alias{get_dates} -\alias{get_dates.default} \alias{get_dates.projections} \title{Access content projections objects} \usage{ -get_dates(x, ...) - -\method{get_dates}{default}(x, ...) - \method{get_dates}{projections}(x, ...) } \arguments{ @@ -30,7 +25,7 @@ objects. They currently include: \examples{ -if (require(distcrete) && require(incidence)) { +if (require(distcrete) && require(incidence)) { withAutoprint({ ## prepare input: epicurve and serial interval dat <- c(0, 2, 2, 3, 3, 5, 5, 5, 6, 6, 6, 6) @@ -49,8 +44,7 @@ pred_1 get_dates(pred_1) max(i$dates) # predictions start 1 day after last incidence -} - +})} } \author{ Thibaut Jombart \email{thibautjombart@gmail.com} diff --git a/man/subset.Rd b/man/subset.Rd index ee98df0..a1a06f0 100644 --- a/man/subset.Rd +++ b/man/subset.Rd @@ -9,7 +9,8 @@ \usage{ \method{[}{projections}(x, i, j) -\method{subset}{projections}(x, ..., from = NULL, to = NULL, sim = TRUE) +\method{subset}{projections}(x, ..., from = NULL, to = NULL, + sim = TRUE) } \arguments{ \item{x}{An projections object, generated by the function