Calculate vmt for each trip
Usage
hts_calculate_vmt(
data,
trip_name = "trip",
ids = c("hh_id", "person_id", "day_id", "trip_id", "vehicle_id"),
agg_tbl = "trip",
mode_cols,
miles_col,
vehicle_modes,
occupancy_var = NULL
)
Arguments
- data
List of data tables
- trip_name
Name of trip table in data
- ids
Unique id in order for each table in data
- agg_tbl
Table to append vmt to
- mode_cols
Column(s) in trip_dt containing trip mode
- miles_col
Column in trip_dt containing miles per trip
- vehicle_modes
List of modes that are considered vehicle
- occupancy_var
Ocuupancy column to divide distance by if specified. Default is NULL
Examples
hts_calculate_vmt(
trip_name = "trip",
data = test_data,
agg_tbl = "day",
mode_cols = c("mode_1", "mode_2"),
miles_col = "distance_miles",
vehicle_modes = c(6, 7, 10)
)
#> day_id person_id delivery_2 delivery_3 delivery_4 delivery_5 delivery_6
#> 1: 1 820 995 995 995 995 995
#> 2: 2 24 0 0 0 0 0
#> 3: 3 1866 0 0 0 0 0
#> 4: 4 1915 995 995 995 995 995
#> 5: 5 415 0 0 0 1 0
#> ---
#> 4121: 4121 1321 0 1 0 1 0
#> 4122: 4122 1619 0 0 0 0 0
#> 4123: 4123 886 995 995 995 995 995
#> 4124: 4124 964 0 0 0 0 0
#> 4125: 4125 1684 0 0 0 0 0
#> delivery_7 delivery_8 delivery_996 travel_date begin_day end_day hh_id
#> 1: 995 995 995 2023-05-28 1 1 642
#> 2: 0 0 1 2023-05-23 1 1 24
#> 3: 0 0 1 2023-05-25 1 1 888
#> 4: 995 995 995 2023-04-17 1 1 875
#> 5: 0 0 0 2023-05-26 1 1 976
#> ---
#> 4121: 0 0 0 2023-05-20 1 1 595
#> 4122: 0 0 1 2023-04-09 1 1 47
#> 4123: 995 995 995 2023-04-12 995 995 474
#> 4124: 0 0 1 2023-04-22 1 1 764
#> 4125: 0 0 1 2023-05-30 1 1 876
#> num_trips day_weight vmt
#> 1: 5 583 0.07736261
#> 2: 5 220 4.96664814
#> 3: 2 73 0.00000000
#> 4: 6 63 70.00022978
#> 5: 3 139 30.63127183
#> ---
#> 4121: 1 755 2.48464220
#> 4122: 5 996 11.25108555
#> 4123: 5 818 18.06692119
#> 4124: 2 460 0.80502711
#> 4125: 5 762 27.65637803
hts_calculate_vmt(
data = test_data,
trip_name = "trip",
agg_tbl = "trip",
mode_cols = "mode_type",
miles_col = "distance_miles",
vehicle_modes = 8,
occupancy_var = "num_travelers"
)
#> day_id trip_id speed_mph distance_miles mode_type mode_1 mode_2
#> 1: 1 6848 0.3570582 0.07736261 8 6 995
#> 2: 1 6099 3.8030030 0.31691692 8 34 995
#> 3: 1 15759 9.2827577 0.16244826 1 1 995
#> 4: 1 13883 10.7289440 10.72894403 13 2 23
#> 5: 1 9240 1.3936891 0.47308002 2 2 995
#> ---
#> 15870: 4125 4505 16.3377147 3.23577517 8 6 995
#> 15871: 4125 7897 42.9297111 22.65734754 8 6 995
#> 15872: 4125 719 1.5648402 7.77203953 1 1 995
#> 15873: 4125 14260 10.5795319 1.76325532 8 7 995
#> 15874: 4125 4397 8.5320851 1.42201419 8 34 995
#> num_travelers d_purpose_category hh_id person_id travel_date trip_weight
#> 1: 1 7 642 820 2023-05-28 957
#> 2: 2 7 642 820 2023-05-28 237
#> 3: 1 9 642 820 2023-05-28 287
#> 4: 1 11 642 820 2023-05-28 361
#> 5: 1 1 642 820 2023-05-28 578
#> ---
#> 15870: 1 12 876 1684 2023-05-30 999
#> 15871: 1 2 876 1684 2023-05-30 167
#> 15872: 1 12 876 1684 2023-05-30 954
#> 15873: 1 2 876 1684 2023-05-30 841
#> 15874: 2 7 876 1684 2023-05-30 977
#> vmt
#> 1: 0.07736261
#> 2: 0.15845846
#> 3: 0.00000000
#> 4: 0.00000000
#> 5: 0.00000000
#> ---
#> 15870: 3.23577517
#> 15871: 22.65734754
#> 15872: 0.00000000
#> 15873: 1.76325532
#> 15874: 0.71100709