#'
#' @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
#' @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)
read.csv(ts_data)
else
ts_data
+ # Convert to the desired timezone (usually "GMT" or "Europe/Paris")
+ formatted_dates_POSIXlt = strptime(as.character(ts_df[,1]), date_format, tz=input_tz)
+ ts_df[,1] = format(as.POSIXct(formatted_dates_POSIXlt, tz=input_tz), tz=working_tz, usetz=TRUE)
+
exo_df =
if (is.character(exo_data))
read.csv(exo_data)
else
exo_data
- # Convert to the desired timezone (usually "GMT" or "Europe/Paris")
- formatted_dates_POSIXlt = strptime(as.character(ts_df[,1]), date_format, tz=input_tz)
- ts_df[,1] = format(as.POSIXct(formatted_dates_POSIXlt), tz=working_tz, usetz=TRUE)
+ # Times in exogenous variables file are ignored: no conversions required
line = 1 #index in PM10 file (24 lines for 1 cell)
nb_lines = nrow(ts_df)
serie = c(serie, ts_df[line,2])
line = line + 1
};
- if (line >= nb_lines + 1 || as.POSIXlt(ts_df[line-1,1])$hour == predict_at)
+ if (line >= nb_lines + 1 || as.POSIXlt(ts_df[line-1,1],tz=working_tz)$hour == predict_at)
break
}
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
}