From 046accb5a2ed001268b11e17a46dbc4b78cb48f4 Mon Sep 17 00:00:00 2001 From: gisler Date: Sun, 5 Jul 2020 09:56:01 +0200 Subject: [PATCH] examples make sure required package versions are installed --- NEWS.md | 2 +- R/Swrappers.R | 3 ++- man/colapply.DTSg.Rd | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0404ecf..dc3a033 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,7 @@ ## DTSg v0.5.0.9000 * Added `subset` method: allows for filtering rows and/or selecting columns of a `DTSg` object -* Added `setCols` method: allows for setting the values of columns, adding columns to and/or removing columns from a `DTSg` object +* Added `setCols` method: allows for setting the values of columns of, adding columns to and/or removing columns from a `DTSg` object * Added `[` extract operator: acts as a shortcut for the `getCol` method * Added examples to the documentation of the `colapply` method showing how to calculate moving averages with the help of the `runner` package instead of the `rollapply` method * `aggregate` method can benefit from `data.table`'s *GForce* optimisation now if its `fun` argument is provided with a character vector specifying summary functions diff --git a/R/Swrappers.R b/R/Swrappers.R index 110250c..dd1393a 100644 --- a/R/Swrappers.R +++ b/R/Swrappers.R @@ -283,7 +283,8 @@ colapply <- function(x, ...) { #' #' # calculate moving averages with the help of 'runner' (all four given #' # approaches provide the same result with explicitly missing timestamps) -#' if (requireNamespace("runner", quietly = TRUE)) { +#' if (requireNamespace("runner", quietly = TRUE) && +#' packageVersion("runner") >= numeric_version("0.3.5")) { #' wrapper <- function(..., .helpers) { #' runner::runner(..., idx = .helpers[[".dateTime"]]) #' } diff --git a/man/colapply.DTSg.Rd b/man/colapply.DTSg.Rd index b971cb5..6bf2b07 100644 --- a/man/colapply.DTSg.Rd +++ b/man/colapply.DTSg.Rd @@ -91,7 +91,8 @@ colapply(x = x, fun = function(x, ...) {cumsum(x)}, funby = byYm____) # calculate moving averages with the help of 'runner' (all four given # approaches provide the same result with explicitly missing timestamps) -if (requireNamespace("runner", quietly = TRUE)) { +if (requireNamespace("runner", quietly = TRUE) && + packageVersion("runner") >= numeric_version("0.3.5")) { wrapper <- function(..., .helpers) { runner::runner(..., idx = .helpers[[".dateTime"]]) }