library(tibble)
library(lubridate)
library(dplyr)
sample <- tibble::tibble(Datetime = c("2023-08-29 6:00:00",
"2023-08-29 23:00:00",
"2023-08-30 6:00:00",
"2023-08-30 22:00:00",
"2023-08-31 6:30:00",
"2023-09-01 1:00:00"),
State = rep(c("wake", "sleep"), 3),
Id = "Participant")
#intervals from sample
sc2interval(sample)
#compare sample (y) and intervals (x)
sc2interval(sample) %>%
mutate(Datetime = int_start(Interval)) %>%
dplyr::left_join(sample, by = c("Id", "State"),
relationship = "many-to-many") %>%
head()
Run the code above in your browser using DataLab