Add Relative Time in minutes to DataFrame. Rows before the start_time will be indicated negative.
Source: R/processing.R
add_relative_time.RdAdd Relative Time in minutes to DataFrame. Rows before the start_time will be indicated negative.
Value
A data frame with an additional column 'relative_timemin' indicating the time in minutes from the start time.
Examples
# Create example data
df <- data.frame(
datetime = as.POSIXct(c("2023-11-13 11:40:00", "2023-11-13 11:45:00", "2023-11-13 11:50:00"))
)
add_relative_time(df)
#> datetime relative_time
#> 1 2023-11-13 11:40:00 0
#> 2 2023-11-13 11:45:00 5
#> 3 2023-11-13 11:50:00 10
add_relative_time(df, start_time = "2023-11-13 11:45:00")
#> datetime relative_time
#> 1 2023-11-13 11:40:00 -5
#> 2 2023-11-13 11:45:00 0
#> 3 2023-11-13 11:50:00 5