| trip | R Documentation |
Include trip related categorical and numeric variables.
trip
A data frame with 921590 rows (each row is a trip) and 8 columns
Household identifier. Use both this variable and person_id to join the trip dataset and the person dataset. Use this variable to join the trip dataset and the house dataset.
Person identifier. Use both this variable and household_id to join the trip dataset and the person dataset.
Generalized purpose of trip on travel day. A travel day is a 24-hour day that starts at 4:00 a.m. (local time) of the assigned travel day and ends at 3:59 a.m. of the following day. The NHTS randomly assigns the travel days for one-seventh of the sample addresses to each day of the week and the remaining six-sevenths of the households to evenly across weekdays (Monday-Friday).
Price of gasoline, in cents, on respondent's travel day.
Number of people on trip including respondent on respondent's travel day.
Trip distance in miles on respondent's travel day, derived from route geometry returned. Google Maps was used for routing the shortest path for motorized travel on the road network. Non-motorized modes, like walk and bike, had the shortest path calculated using network routes paths.
Trip duration in minutes on respondent's travel day.
Trip distance in miles for personally driven vehicle trips on respondent's travel day. -1 = Appropriate skip.
if (require("tidyverse")) {
# Filtered to shorter trips for a clearer introductory visualization
short_trips <- trip |>
filter(trip_miles <= 50,
trip_duration <= 180)
# Filtered to trips with positive distance and duration
positive_distance_trips <- short_trips |>
filter(trip_miles > 0,
trip_duration > 0)
# Fit a simple linear regression model
duration_miles_model <- lm(trip_duration ~ trip_miles,
data = positive_distance_trips)
summary(duration_miles_model)
# Correlation between trip distance and trip duration
cor(positive_distance_trips$trip_miles, positive_distance_trips$trip_duration)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.