Takes a vector of HH:MM (HH:MM:SS) information and categorizes these by a 4 level factor of time of day.

time_factor(x, time_func = lubridate::hms, tod = time_of_day())

Arguments

x

character vector of times

time_func

a function to convert x to a lubridate time vector. Default is lubridate::hms

tod

list defining when the breakpoints for the various time of day distinctions.

Value

factor vector

Examples

time_factor(c("12:23", "15:59", "22:10", "8:13"))
#> Warning: There was 1 warning in `mutate()`.
#>  In argument: `time = time_func(x)`.
#> Caused by warning in `.parse_hms()`:
#> ! Some strings failed to parse, or all strings are NAs
#> [1] <NA> <NA> <NA> <NA>
#> Levels: morning < afternoon < evening < night