diff --git a/R/import_helpers.R b/R/import_helpers.R index cc4d443..00e935f 100644 --- a/R/import_helpers.R +++ b/R/import_helpers.R @@ -35,6 +35,10 @@ long_to_ts <- function(data, keep_last_freq_only = FALSE, force_xts = FALSE) { data_dt <- data_dt[!(series %in% empty_series[is_empty == TRUE, series])] + if(nrow(data_dt) == 0) { + return(list()) + } + data_dt[, `:=`(date_zoo = as.numeric(as.yearmon(date)), frq = 12), by = series] data_dt[is.na(date_zoo), `:=`(date_zoo = as.numeric(as.yearqtr(date)), frq = 4)]