advance on tests
[talweg.git] / pkg / R / getData.R
index 153a660..205ee5d 100644 (file)
@@ -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
                }