This function is used to adjust the timestamps in a dataset by shifting them
either to match the first event in the entire dataset ('time') or to show
elapsed time since the first event in each group ('elapsed').
Note that this function assumes that the dataframe is already grouped.
It is recommended to use df %>% group_by() %>% set_alignment(...)
when calling this function.
Usage
set_alignment(df, datetime_col, alignment)
Arguments
- df
A grouped dataframe that contains the datetime data to be aligned.
- datetime_col
The name of the datetime column to be aligned.
- alignment
The type of alignment to be done. It can be either 'time' or 'elapsed'.
Value
A dataframe with the new alignment.
Examples
if (FALSE) { # \dontrun{
df %>%
dplyr::group_by(group_col) %>%
set_alignment(datetime_col = your_datetime_column, alignment = "time")
} # }