From 49181abbc59a7e7695a53c5ec501524e3d99b8a5 Mon Sep 17 00:00:00 2001
From: Delaigue Olivier <olivier.delaigue@irstea.fr>
Date: Wed, 8 Apr 2020 10:19:01 +0200
Subject: [PATCH] v1.4.3.79 CLEAN: multiple "if" conditions to select the
 TimeFormat in SeriesAggreg replaced by the use of the switch function

---
 DESCRIPTION      |  2 +-
 NEWS.md          |  2 +-
 R/SeriesAggreg.R | 17 +++++------------
 3 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index cab58d0c..241c9971 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.3.78
+Version: 1.4.3.79
 Date: 2020-04-06
 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 7a5b23da..703b55bf 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -4,7 +4,7 @@
 
 
 
-### 1.4.3.78 Release Notes (2020-04-06)
+### 1.4.3.79 Release Notes (2020-04-06)
 
 #### CRAN-compatibility updates
 
diff --git a/R/SeriesAggreg.R b/R/SeriesAggreg.R
index e973aa2b..763e4221 100644
--- a/R/SeriesAggreg.R
+++ b/R/SeriesAggreg.R
@@ -69,18 +69,11 @@ SeriesAggreg <- function(TabSeries,
     stop("'YearFirstMonth' must be only one integer between 1 and 12")
   } 
   ##check_DatesR_integrity
-  if (TimeFormat == "hourly") {
-    by <- "hours"
-  }
-  if (TimeFormat == "daily") {
-    by <- "days"
-  }
-  if (TimeFormat == "monthly") {
-    by <- "months"
-  }
-  if (TimeFormat == "yearly") {
-    by <- "years"
-  }
+  by <- switch(TimeFormat,
+               'hourly'  = "hours",
+               'daily'   = "days",
+               'monthly' = "months",
+               'yearly'  = "years")
   TmpDatesR <- seq(from = TabSeries[1, 1], to = tail(TabSeries[, 1], 1), by = by)
   if (!identical(TabSeries[, 1], TmpDatesR)) {
     stop("some dates might not be ordered or are missing in 'TabSeries'")
-- 
GitLab