X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=pkg%2FR%2FgetData.R;h=e13cf86cb8ae578e4bad37b65a9e5ca2ccdc40a0;hb=6deb700590d0000c4f8cce050990394f381ddecf;hp=a4e1e17b2e1808568dc5b0dd88cbaf5f86abbb26;hpb=ff5df8e310b73883565761ab4b1aa5a0672e9f27;p=talweg.git diff --git a/pkg/R/getData.R b/pkg/R/getData.R index a4e1e17..e13cf86 100644 --- a/pkg/R/getData.R +++ b/pkg/R/getData.R @@ -49,14 +49,16 @@ getData = function(ts_data, exo_data, input_tz="GMT", date_format="%d/%m/%Y %H:% 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) @@ -74,7 +76,7 @@ getData = function(ts_data, exo_data, input_tz="GMT", date_format="%d/%m/%Y %H:% 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 }