read_data: Read HTS data, weights, metadata, etc.

View source: R/read_data.R

read_dataR Documentation

Read HTS data, weights, metadata, etc.

Description

Read HTS data, weights, metadata, etc.

Usage

read_data(study, project_path)

Arguments

study

character. A valid study name.

project_path

character. The project directory.

Details

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.

Value

read_data returns an object of class "HTS.data". It contains the data files and weights necessary for querying the HTS datasets, 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.

Examples


# Read the data
hts_data <- read_data(
  study = 'nirpc_2018',
  project_path = 'C:/2018 NIRPC Household Travel Survey'
)

# Access the data
hts_data$data$household     # household data
hts_data$data$person        # person data
hts_data$data$trip          # trip data
hts_data$data$vehicle       # vehicle data

# Access the weights
hts_data$weights$household  # household weights
hts_data$weights$person     # person and trip weights



Westat-Transportation/surveysummarize documentation built on Oct. 20, 2023, 2:44 a.m.