Skip to contents

Calculates the number of complete weekdays for each household using survey diary data and project settings. Use to identify valid households for weighting and analysis.

Usage

calc_complete_hhdays(households, days, settings, include_zeros = FALSE)

Arguments

households

data.table with required columns:

  • hh_id <character/integer> — household ID

  • diary_platform — survey diary method Rows: one per household. Keys: (hh_id). Modified by reference: no (returns copy).

days

data.table with required columns:

  • hh_id <character/integer> — household ID

  • travel_dow — day of week

  • hh_day_complete — complete day indicator Rows: one per day. Keys: (hh_id, travel_dow). Modified by reference: no (returns copy).

settings

list. Must include:

  • weight_dow_groups

include_zeros

logical. Include households with zero complete weekdays. Default: FALSE.

Value

data.table with columns:

  • hh_id <character/integer> — household ID

  • day_group — day group assigned

  • n_complete_hh_days — number of complete weekdays

  • diary_platform — survey diary method

  • hh_id_dow — combined household and day group ID Rows: one per household-day group. Keys: (hh_id, day_group). Modified by reference: no (returns copy).

Details

  • Uses day table and household table to count complete weekdays by group.

  • Assigns day group using get_day_groups(settings).

  • Merges diary platform from households.

  • Optionally includes households with zero complete weekdays.

  • Checks for valid diary platform and complete day counts.

  • Returns a copy; does not modify by reference.

Settings

  • weight_dow_groups (direct): Day-of-week groups for weighting. Default from config/settings.json.

See also

Examples

## Not run:
# households <- ... # household data
# days <- ... # day data
# settings <- ... # pipeline settings
# result <- calc_complete_hhdays(households, days, settings)
## End(Not run)