rules2timebins: Converts a list of human readable rules to a functional that...

View source: R/time_bins.R

rules2timebinsR Documentation

Converts a list of human readable rules to a functional that maps any datetime stamp to a time bin.

Description

Converts a list of human readable rules to a functional that maps any datetime stamp to a time bin.

Usage

rules2timebins(rules)

Arguments

rules

A list of lists of rules, each sublist must contain 4 variables, start and end as the start and end times (24h) format of the time bin, days as a vector of days to apply this time bin to (1 for Sunday, ..., 7 for Saturday), and tag the name of the time bin.

Details

Unassigned time is by default tagged with Other

Value

a function that maps any datetime stamp to the associated time bins.

Examples

## Not run: 
rules = list(
    list(start='6:30',  end= '9:00',  days = 1:5, tag='MR'),
    list(start='15:00', end= '18:00', days = 2:5, tag='ER')
)
time_bins <- rules2timebins(rules)
time_bins(Sys.time())

## End(Not run)

melmasri/traveltimeHMM documentation built on Jan. 6, 2023, 10:30 p.m.