'update'
[talweg.git] / pkg / R / getData.R
index da4b459..a4e1e17 100644 (file)
@@ -2,8 +2,7 @@
 #'
 #' @description Take in input data frames and/or files containing raw data, and timezones, and
 #'   output a Data object, roughly corresponding to a list where each cell contains all value
-#'   for one day (see \code{?Data}). Current limitation: series (in working_tz) must start at
-#'   right after midnight (to keep in sync with exogenous vars)
+#'   for one day (see \code{?Data}).
 #'
 #' @param ts_data Time-series, as a data frame (DB style: 2 columns, first is date/time,
 #'   second is value) or a CSV file
@@ -21,7 +20,7 @@
 #' @examples
 #' ts_data = read.csv(system.file("extdata","pm10_mesures_H_loc.csv",package="talweg"))
 #' exo_data = read.csv(system.file("extdata","meteo_extra_noNAs.csv",package="talweg"))
-#' getData(ts_data, exo_data, input_tz="Europe/Paris", working_tz="Europe/Paris", limit=150)
+#' data = getData(ts_data, exo_data, limit=120)
 #' @export
 getData = function(ts_data, exo_data, input_tz="GMT", date_format="%d/%m/%Y %H:%M",
        working_tz="GMT", predict_at=0, limit=Inf)
@@ -88,13 +87,12 @@ getData = function(ts_data, exo_data, input_tz="GMT", date_format="%d/%m/%Y %H:%
                        break
                i = i + 1
        }
-       if (length(data$getCenteredSerie(1)) < length(data$getCenteredSerie(1)))
+       if (length(data$getCenteredSerie(1)) < length(data$getCenteredSerie(2)))
                data$removeFirst()
-       if (length(data$getCenteredSerie( data$getSize() )) <
-               length(data$getCenteredSerie( data$getSize()-1 )))
+       if (length(data$getCenteredSerie(data$getSize()))
+               < length(data$getCenteredSerie(data$getSize()-1)))
        {
                data$removeLast()
        }
-
        data
 }