View source: R/combine_epochs_periods.R
combine_epochs_periods | R Documentation |
Suppose we have used apply_tudor_locke()
to detect sleep periods
or apply_troiano()
/apply_choi()
to detect non-wear periods.
It might be useful to combine the epochs data with the periods data, so
that each epoch is labeled according to which period it falls into, if
any. Then we can easily slice the epochs data by sleep/non-sleep or
wear/non-wear.
combine_epochs_periods(epochs, periods, start_var, end_var)
epochs |
A |
periods |
A summary |
start_var |
The |
end_var |
The |
A tibble
of activity data with one additional column,
period_id
, which indicates the period each epoch falls into.
library("dplyr") data("gtxplus1day") agdb <- gtxplus1day %>% collapse_epochs(60) %>% apply_sadeh() periods <- agdb %>% apply_tudor_locke(min_sleep_period = 60) agdb_with_periods <- combine_epochs_periods( agdb, periods, in_bed_time, out_bed_time ) # How many sleep periods were detected and what is their duration, # in minutes? periods %>% select(in_bed_time, out_bed_time, duration) # What is the assignment of epochs to periods? agdb_with_periods %>% count(period_id)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.