mark_time_periods: Mark time periods for analysis and bell time in raw data

View source: R/mark_time_periods.R

mark_time_periodsR Documentation

Mark time periods for analysis and bell time in raw data

Description

Creates binary columns indicating whether each timestamp falls within specified time periods (e.g., recess period, bell ringing period)

Usage

mark_time_periods(
  data,
  time_col = "At",
  analyze_start,
  analyze_end,
  bell_start = NULL,
  bell_end = NULL,
  analyze_col = "Analyze",
  bell_col = "Bell"
)

Arguments

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. "2025-03-18 11:50:00")

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")

Value

Data frame with added binary columns (1 = within period, 0 = outside period)

Examples

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"
)

trackclean documentation built on July 1, 2026, 5:07 p.m.