Skip to contents

Calculates tour weights for each person in each household by averaging unlinked trip weights within tour groups. Use to generate tour weights for downstream analysis.

Usage

calc_tour_weights(
  tours,
  unlinked_trips,
  unlinked_trip_weights,
  day_weights,
  settings,
  ignore_checks = FALSE
)

Arguments

tours

data.table with required columns:

  • tour_id

  • hh_id

  • person_id

  • day_id

  • day_group Rows: one per tour. Keys: (tour_id). Modified by reference: no (returns copy).

unlinked_trips

data.table. Unlinked trip-level variables.

unlinked_trip_weights

data.table. Unlinked trip weights.

day_weights

data.table. Day-level weights.

settings

list. Pipeline settings object.

ignore_checks

logical. If TRUE, skips consistency checks.

Value

data.table with columns:

  • hh_id

  • person_id

  • day_id

  • tour_id

  • day_group

  • tour_weight Rows: one per tour. Keys: (tour_id).

Details

  • Joins tour IDs to unlinked trip weights.

  • Averages unlinked trip weights by tour ID.

  • Checks consistency with day weights unless ignore_checks is TRUE.

  • Returns a copy; does not modify by reference.

Settings

None.

Examples

## Not run:
tours <- data.table(tour_id = "T1", hh_id = 1, person_id = 1, day_id = 1, day_group = "weekday")
unlinked_trips <- data.table()
unlinked_trip_weights <- data.table()
day_weights <- data.table()
settings <- list()
calc_tour_weights(tours, unlinked_trips, unlinked_trip_weights, day_weights, settings)
#> Error in colnamesInt(x, names(on), check_dups = FALSE): argument specifying columns received non-existing column(s): cols[1]='trip_id'
## End(Not run)