From 0b75c40d864187ca0e3a2226c9b5c10be7ce4772 Mon Sep 17 00:00:00 2001 From: thoenis Date: Wed, 5 Dec 2018 14:48:23 +0100 Subject: [PATCH] Make read_swissdata_meta return something for missing locales --- R/read_swissdata_meta.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/R/read_swissdata_meta.R b/R/read_swissdata_meta.R index 7006ed2..6bfe6d0 100644 --- a/R/read_swissdata_meta.R +++ b/R/read_swissdata_meta.R @@ -40,6 +40,16 @@ read_swissdata_meta <- function(path, locale = "de", as_list = FALSE) { # Now this is some serious R-Fu labels <- expand.grid(lapply(meta_labels, sapply, `[[`, locale), stringsAsFactors = FALSE, KEEP.OUT.ATTRS = FALSE) + if(all(sapply(labels, sapply, is.null) == TRUE)) { + if(as_list) { + out <- lapply(keys, function(x) { NULL }) + names(out) <- keys + return(out) + } else { + return(data.table(ts_key = keys)) + } + } + # Work some dark magic to get units into it? # Is this smert? dimnames could be any old crazy strings