View source: R/mark_time_periods.R
| mark_time_periods | R Documentation |
Creates binary columns indicating whether each timestamp falls within specified time periods (e.g., recess period, bell ringing period)
mark_time_periods(
data,
time_col = "At",
analyze_start,
analyze_end,
bell_start = NULL,
bell_end = NULL,
analyze_col = "Analyze",
bell_col = "Bell"
)
data |
A data frame with timestamp data |
time_col |
Name of the timestamp column (default: "At") |
analyze_start |
Start time for analysis period (POSIXct or character, e.g. |
analyze_end |
End time for analysis period (POSIXct or character) |
bell_start |
Start time for bell period (POSIXct or character, optional) |
bell_end |
End time for bell period (POSIXct or character, optional) |
analyze_col |
Name of column to create for analysis period (default: "Analyze") |
bell_col |
Name of column to create for bell period (default: "Bell") |
Data frame with added binary columns (1 = within period, 0 = outside period)
raw_data <- data.frame(
At = as.POSIXct(c("2025-03-18 11:00:00", "2025-03-18 12:00:00",
"2025-03-18 13:00:00")),
ID = 1:3
)
raw_data <- mark_time_periods(
raw_data,
analyze_start = "2025-03-18 10:30:00",
analyze_end = "2025-03-18 12:30:00",
bell_start = "2025-03-18 11:30:00",
bell_end = "2025-03-18 12:30:00"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.