Skip to contents

Transform travel survey data.table to a survey object

Usage

hts_to_so(prepped_dt, weighted = TRUE, wtname = NULL, strataname = NULL)

Arguments

prepped_dt

Dataframe in data.table format to transform to survey object.

weighted

If true creates a weighted survey object. Default is TRUE.

wtname

Name of the weight column in the dataframe. Defaults to NULL, but must exist if weighted is true.

strataname

Name of strata name to bring in. Default is NULL.

Value

Inputted dataframe transformed into a survey object.

Examples


require(data.table)
hts_to_so(prepped_dt = trip, wtname = "trip_weight")
#> Independent Sampling design (with replacement)
#> Called via srvyr
#> Sampling variables:
#>  - ids: `1`
#>  - weights: weight
#> Data variables: day_id (int), trip_id (int), speed_mph (dbl), distance_miles
#>   (dbl), mode_type (int), mode_1 (int), mode_2 (int), num_travelers (int),
#>   d_purpose_category (int), hh_id (int), person_id (int), travel_date (date),
#>   weight (int)