Description Usage Arguments Details Value Examples
Read HTS data and weights.
1 | read_data(dataset, csv_path = getwd(), select = select_all(dataset))
|
dataset |
The study year of the dataset. Currently supports "2001" and "2009". |
csv_path |
The parent directory of "/csv/dataset/". Defaults to working directory. |
select |
A character vector of NHTS variable names to select for analysis. Defaults to all variables in the codebook. |
read_data
is a wrapper for reading in variables from the correct csvs
and merging the corresponding tables on correct keys. fread and
merge are used for performance benefits.
read_data returns an object of class "HTS.data". It contains the data files and weights necessary for querying the NHTS dataset, used primarily by summarize_data.
The "HTS.data" object is essentially a list of data.tables broken up by data and weights.
Accessing the data:
household - Household data file
person - Person data file
trip - Trip data file
vehicle - Vehicle data file
Accessing the weights:
household - Household weight file. Used for weighting household and vehicle data.
person - Person weight file. Also includes trip weights at the person level.
1 2 3 4 5 6 7 8 9 10 11 12 | # Read 2009 NHTS data with specified csv path:
nhts_data <- read_data('2009', csv_path = 'C:/NHTS')
# Access the data
nhts_data$data$household # household data
nhts_data$data$person # person data
nhts_data$data$trip # trip data
nhts_data$data$vehicle # vehicle data
# Access the weights
nhts_data$weights$household # household weights
nhts_data$weights$person # person and trip weights
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.