# Define some data
dat <- data.frame(
participant_id = "12345",
time = as.POSIXct(c("2022-05-10 10:00:00", "2022-05-10 10:30:00", "2022-05-10 11:30:00")),
type = c("WALKING", "STILL", "RUNNING"),
confidence = c(80, 100, 20)
)
# Get the gaps from identify_gaps, but in this example define them ourselves
gaps <- data.frame(
participant_id = "12345",
from = as.POSIXct(c("2022-05-10 10:05:00", "2022-05-10 10:50:00")),
to = as.POSIXct(c("2022-05-10 10:20:00", "2022-05-10 11:10:00"))
)
# Now add the gaps to the data
add_gaps(
data = dat,
gaps = gaps,
by = "participant_id"
)
# You can use fill if you want to get rid of those pesky NA's
add_gaps(
data = dat,
gaps = gaps,
by = "participant_id",
fill = list(type = "GAP", confidence = 100)
)
Run the code above in your browser using DataLab