From 261d4efaeebb99aed032bb01a3d54ea18d7674ec Mon Sep 17 00:00:00 2001 From: bczernecki Date: Wed, 20 Sep 2023 10:30:21 +0200 Subject: [PATCH] assertions for telemetry --- R/meteo_imgw_datastore.R | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/R/meteo_imgw_datastore.R b/R/meteo_imgw_datastore.R index c4b6ca9..9792e48 100644 --- a/R/meteo_imgw_datastore.R +++ b/R/meteo_imgw_datastore.R @@ -47,6 +47,15 @@ meteo_imgw_datastore = function(year, coords = TRUE, allow_failure = TRUE) { + # assertions for year + if (!any(is.character(year) || is.numeric(year))) { + stop("year argument must be character or numeric") + } + + if (!all(as.numeric(year) >= 2008)) { + stop("year argument must be provided and all elements must be >= 2008") + } + if (allow_failure) { tryCatch(meteo_imgw_datastore_bp(year, parameters, @@ -80,7 +89,7 @@ meteo_imgw_datastore_bp = function(year, telemetry_stations$river = NULL if (!is.null(stations)) { - telemetry_stations = telemetry_stations[telemetry_stations$name %in% stations, ] + telemetry_stations = telemetry_stations[telemetry_stations$name %in% toupper(stations), ] } urls = as.character(