Bin numeric variables
Arguments
- prepped_dt
Dataset containing variable to bin in data.table format
- numvar
Name of the numeric variable to bin
- nbins
Number of bins for variable. Defaults to 7.
Examples
require(data.table)
#> Loading required package: data.table
require(stringr)
#> Loading required package: stringr
hts_bin_var(prepped_dt = trip, numvar = "speed_mph")
#> day_id trip_id distance_miles mode_type mode_1 mode_2 num_travelers
#> 1: 1 6848 0.07736261 8 6 995 1
#> 2: 1 6099 0.31691692 8 34 995 2
#> 3: 1 15759 0.16244826 1 1 995 1
#> 4: 1 13883 10.72894403 13 2 23 1
#> 5: 1 9240 0.47308002 2 2 995 1
#> ---
#> 15870: 4125 4505 3.23577517 8 6 995 1
#> 15871: 4125 7897 22.65734754 8 6 995 1
#> 15872: 4125 719 7.77203953 1 1 995 1
#> 15873: 4125 14260 1.76325532 8 7 995 1
#> 15874: 4125 4397 1.42201419 8 34 995 2
#> d_purpose_category hh_id person_id travel_date trip_weight speed_mph
#> 1: 7 642 820 2023-05-28 957 1 or less
#> 2: 7 642 820 2023-05-28 237 1-23
#> 3: 9 642 820 2023-05-28 287 1-23
#> 4: 11 642 820 2023-05-28 361 1-23
#> 5: 1 642 820 2023-05-28 578 1-23
#> ---
#> 15870: 12 876 1684 2023-05-30 999 1-23
#> 15871: 2 876 1684 2023-05-30 167 23-45
#> 15872: 12 876 1684 2023-05-30 954 1-23
#> 15873: 2 876 1684 2023-05-30 841 1-23
#> 15874: 7 876 1684 2023-05-30 977 1-23