diff --git a/DESCRIPTION b/DESCRIPTION index 71a1f82057939411545d2c4d6cfced9a6f1f8e17..96f93165adcefcc6cd4898b977c6b5082535df8a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.4.4.10 +Version: 1.4.4.11 Date: 2020-04-09 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), diff --git a/NEWS.md b/NEWS.md index 7c12087c1d59853f8a4865340af536eb0df7a733..6709e620c1c986820d4f5465177cbde01ec64813 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ -### 1.4.4.10 Release Notes (2020-04-09) +### 1.4.4.11 Release Notes (2020-04-09) #### New features diff --git a/R/SeriesAggreg2.R b/R/SeriesAggreg2.R index 32d0554e9642822b56395c84e37f9d26466dffc3..b39f8874d379f8af094136f415029323c0b98eef 100644 --- a/R/SeriesAggreg2.R +++ b/R/SeriesAggreg2.R @@ -27,6 +27,22 @@ SeriesAggreg2 <- function(TabSeries, Format, ConvertFun, listFormat <- c("%Y%m%d", "%Y%m", "%Y", "%m", "%d") Format <- gsub(pattern = "[[:punct:]]+", replacement = "%", Format) Format <- match.arg(Format, choices = listFormat) + ## check ConvertFun + if (!is.vector(ConvertFun)) { + stop("'ConvertFun' must be a vector of character") + } + if (!is.character(ConvertFun)) { + stop("'ConvertFun' must be a vector of character") + } + if (length(ConvertFun) != (ncol(TabSeries) - 1)) { + stop( + sprintf("'ConvertFun' must be of length %i (ncol(TabSeries)-1)", ncol(TabSeries) - 1) + ) + } + if (!all(ConvertFun %in% c("sum", "mean"))) { + stop("'ConvertFun' should be one of 'sum' or 'mean'") + } + sp <- sprintf("%02.f", YearFirstMonth)