From 7a84f223c498055abf9762e29a2bf3193fc9f0e3 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Wed, 22 Aug 2018 15:08:57 +0100 Subject: [PATCH 1/4] import get_dates from incidence There was a bit of a namespace clash the new get_dates from incidence. This commit removes the generic and imports get_dates from incidence. --- DESCRIPTION | 3 ++- NAMESPACE | 3 +-- R/accessors.R | 21 +-------------------- man/plot.projections.Rd | 10 +++++----- man/projections_accessors.Rd | 9 +-------- man/subset.Rd | 3 ++- 6 files changed, 12 insertions(+), 37 deletions(-) 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..69bbb9e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,15 +4,14 @@ 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) S3method(subset,projections) export(add_projections) export(build_projections) -export(get_dates) export(project) importFrom(graphics,plot) importFrom(incidence,cumulate) +importFrom(incidence,get_dates) importFrom(stats,as.ts) diff --git a/R/accessors.R b/R/accessors.R index e464b57..07cb51c 100644 --- a/R/accessors.R +++ b/R/accessors.R @@ -41,27 +41,8 @@ #' 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 - +#' @importFrom incidence get_dates 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..88aadc3 100644 --- a/man/projections_accessors.Rd +++ b/man/projections_accessors.Rd @@ -1,15 +1,9 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/accessors.R -\name{get_dates} -\alias{get_dates} -\alias{get_dates.default} +\name{get_dates.projections} \alias{get_dates.projections} \title{Access content projections objects} \usage{ -get_dates(x, ...) - -\method{get_dates}{default}(x, ...) - \method{get_dates}{projections}(x, ...) } \arguments{ @@ -50,7 +44,6 @@ 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 From bffcb4449c5b4ff3091fffba30e5f3c9ce15d8ee Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Wed, 22 Aug 2018 16:02:11 +0100 Subject: [PATCH 2/4] add name to get_dates --- R/accessors.R | 7 ++++--- man/projections_accessors.Rd | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/R/accessors.R b/R/accessors.R index 07cb51c..436f6b1 100644 --- a/R/accessors.R +++ b/R/accessors.R @@ -7,7 +7,7 @@ #' \item \code{get_dates}: get dates of the predictions. #' #' } -#' +#' @name get_dates #' @rdname projections_accessors #' #' @author Thibaut Jombart \email{thibautjombart@@gmail.com} @@ -21,7 +21,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,8 +40,9 @@ #' get_dates(pred_1) #' max(i$dates) # predictions start 1 day after last incidence #' -#' } +#' })} #' @aliases get_dates.projections +#' @aliases get_dates #' @importFrom incidence get_dates get_dates.projections <- function(x, ...) { attr(x, "dates") diff --git a/man/projections_accessors.Rd b/man/projections_accessors.Rd index 88aadc3..3717803 100644 --- a/man/projections_accessors.Rd +++ b/man/projections_accessors.Rd @@ -1,6 +1,7 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/accessors.R -\name{get_dates.projections} +\name{get_dates} +\alias{get_dates} \alias{get_dates.projections} \title{Access content projections objects} \usage{ @@ -24,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) @@ -43,7 +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} From 9afb5758a626c0bc8c92b62c83b3aa5b8d199084 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Fri, 24 Aug 2018 11:15:44 +0100 Subject: [PATCH 3/4] explicitly export get_dates This was a solution from Winston Chang in 2014: http://r.789695.n4.nabble.com/R-CMD-check-warning-with-S3-method-td4692255.html --- NAMESPACE | 1 + R/accessors.R | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 69bbb9e..b7e6de4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,7 @@ S3method(print,projections) S3method(subset,projections) export(add_projections) export(build_projections) +export(get_dates) export(project) importFrom(graphics,plot) importFrom(incidence,cumulate) diff --git a/R/accessors.R b/R/accessors.R index 436f6b1..56bfcb9 100644 --- a/R/accessors.R +++ b/R/accessors.R @@ -12,7 +12,6 @@ #' #' @author Thibaut Jombart \email{thibautjombart@@gmail.com} #' -#' @export #' #' @param x A \code{projections} object. #' @@ -44,6 +43,8 @@ #' @aliases get_dates.projections #' @aliases get_dates #' @importFrom incidence get_dates +#' @export get_dates +#' @export get_dates.projections <- function(x, ...) { attr(x, "dates") } From 9f2539013dea5d8b49b410bfc2beff4357f9d030 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Fri, 24 Aug 2018 11:16:32 +0100 Subject: [PATCH 4/4] update NEWS --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) 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