X-Git-Url: https://git.auder.net/?p=talweg.git;a=blobdiff_plain;f=pkg%2FR%2FgetData.R;h=205ee5d516a89099b2a99aaf969d4d4c0e2d6754;hp=153a660f35a56667342232331fdad2c8992b8f97;hb=6d97bfecf7310ed6682eecce1b7aa2f8185d4742;hpb=a65907cc939a5fe419613d3ba555b1d1c1af97d3 diff --git a/pkg/R/getData.R b/pkg/R/getData.R index 153a660..205ee5d 100644 --- a/pkg/R/getData.R +++ b/pkg/R/getData.R @@ -26,10 +26,13 @@ getData = function(ts_data, exo_data, input_tz="GMT", date_format="%d/%m/%Y %H:% stop("Bad timezone (see ?timezone)") input_tz = input_tz[1] working_tz = working_tz[1] - if (!is.data.frame(ts_data) && !is.character(ts_data)) - stop("Bad time-series input (data frame or CSV file)") + if ( (!is.data.frame(ts_data) && !is.character(ts_data)) || + (!is.data.frame(exo_data) && !is.character(exo_data)) ) + stop("Bad time-series / exogenous input (data [frame] or CSV file)") if (is.character(ts_data)) ts_data = ts_data[1] + if (is.character(exo_data)) + exo_data = exo_data[1] predict_at = as.integer(predict_at)[1] if (predict_at<0 || predict_at>23) stop("Bad predict_at (0-23)") @@ -39,7 +42,19 @@ getData = function(ts_data, exo_data, input_tz="GMT", date_format="%d/%m/%Y %H:% ts_df = if (is.character(ts_data)) { - read.csv(ts_data) + if (ts_data %in% data(package="talweg")$results[,"Item"]) + ts_data = + + + + + ############CONTINUE: http://r-pkgs.had.co.nz/data.html + + + + + + read.csv(ts_data) } else { ts_data }