lundi 27 juillet 2020

conditionally formatting different time series types in R

I'm newer to R and I've been having trouble trying to conditionally format data I guess.

I have a df of temperatures and time series and another df of storm data. My end goal would be to set each storm start time to t=0 so I could create a scatter plot of temperatures

  1. Add storm number(SN) to df_Temps

my only idea:ifelse(df_Temps$DATETIME >= df_STORM$start.time & df_Temps$DATETIME <= df_STORM$end.time, df_Temps$SN <- df_STORM$SN)

  1. omit.na each row without a number in df_Temps$SN

df_Temps <- df_Temps[!is.na(df_Temps$SN),]

  1. Get the start of each storm to have t=0

end goal

DATETIME    temps   SN
HH:00:00    …       1
HH:15:00    …       1
HH:30:00    …       1
HH:00:00    …       2
HH:15:00    …       2
HH:00:00    …       3

df_Temps example (currently in 15min intervals be 3 year of data, but have 3min data)

DATETIME            T1      T2      T3      T4
YYYY:MM:DD HH:00:00 82.2    83.45   84.51   85.61
YYYY:MM:DD HH:15:00 …       …       …       …
YYYY:MM:DD HH:30:00 …       …       …       …
YYYY:MM:DD HH:45:00 …       …       …       …

df_STORM example

SN  Inches  start.time          end.time
1   x       2017-07-08 12:59:00 2017-07-08 14:45:00
2   x       YYYY:MM:DD HH:MM:SS YYYY:MM:DD HH:MM:SS
3   x       YYYY:MM:DD HH:MM:SS YYYY:MM:DD HH:MM:SS
4   x       YYYY:MM:DD HH:MM:SS YYYY:MM:DD HH:MM:SS
…   …       …           …

Thank you for any advice or suggestions

Aucun commentaire:

Enregistrer un commentaire