r - Combine information from hi-resolution time series with another with daily information -


i have measurement data - - 1 minute resolution, irregular.

timeseries   time                signal 1 2015-03-30 00:00:00   17.3 2 2015-03-30 00:01:00   16.2 3 2015-03-30 00:02:01   18.4 4 2015-03-30 00:04:03   17.7 

in second data frame, have daily information.

dailyinfo   firstevent          yesterday 1 2015-03-28 17:01:43 2015-03-27 15:25:51 2 2015-03-29 17:04:55 2015-03-28 17:01:43 3 2015-03-30 16:59:03 2015-03-29 17:04:55 

the dailyinfo$firstevent boundaries. want like

timeseries %>%    group_by(between(time, dailyinfo$yesterday, dailyinfo$firstevent)) 

in tutorials, information present within 1 data frame (e.g. iris %>% group_by(species) %>% ...).

my workaround count number of rows between each set of boundaries, replicate firstevent-entry often, concatenate , put resulting vector timeseries new column.

this not elegant, maybe can me how use dplyr this?

use cut

timeseries %>%     mutate(interval = cut(time, dailyinfo$firstevent)) %>%     group_by(interval) 

or calculate intervals directly in group_by

timeseries %>%     group_by(interval = cut(time, dailyinfo$firstevent))                   time signal            interval 1 2015-03-30 00:00:00   17.3 2015-03-29 17:04:55 2 2015-03-30 00:01:00   16.2 2015-03-29 17:04:55 3 2015-03-30 00:02:01   18.4 2015-03-29 17:04:55 4 2015-03-30 00:04:03   17.7 2015-03-29 17:04:55 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -