#creating a simple TRUE/FALSE state in the sample data: Light above 250 lx mel EDI
#and a second state that cuts data into chunks relating to the Brown et al. 2022 thresholds
#(+aggregating Data to 5 minute intervals & reducing it to three days)
state_data <-
sample.data.environment |>
dplyr::mutate(state = MEDI > 250) |>
Brown_cut(MEDI, state2) |>
aggregate_Datetime(unit = "5 mins") |>
filter_Datetime(length = "3 days")
state_data |>
gg_days() |>
gg_state(state)
#state 2 has more than one valid state, thus we need to assign a fill aesthetic
state_data |>
gg_days() |>
gg_state(state2, aes_fill = state2) +
ggplot2::scale_fill_manual(values=c("#868686FF", "#EFC000FF", "#0073C2FF"))
#this line is simply for sensible colors
#same, but with gg_day()
state_data |>
dplyr::filter(Id == "Participant") |>
gg_day(geom = "line") |>
gg_state(state, fill = "red")
#more complex state
state_data |>
dplyr::filter(Id == "Participant") |>
gg_day(geom = "line") |>
gg_state(state2, aes_fill = state2)
#with gg_doubleplot
state_data |>
dplyr::filter(Id == "Participant") |>
gg_doubleplot() |>
gg_state(state2, aes_fill = state2)
Run the code above in your browser using DataLab