Calculate traveled time from the naturalistic data
nds_calc_time.Rd
nds_calc_time
extracts traveled time from the naturalistic data.
Arguments
- data
A tibble or data.frame object containing naturalistic data
- by
A column name to group the results
- units
The desired time unit ("seconds", "minutes" or "hours")
- valid
Option to select all data or valid data ("all", "yes").
Details
This function uses a naturalistic data sample (nds_load_data) as main
input and extracts its traveled time, grouping the results by the attributes
of the desired variable (parameter by
). The time unit can be in
"seconds" (default), "minutes" or "hours". It is possible to filter only
valid time data using the valid
parameter. In it's default, the
function uses all data, including invalid times.
Examples
path <- system.file("extdata", package = "ndsbr")
df <- nds_load_data("driver", path)
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
nds_calc_time(df, "DRIVER")
#> # A tibble: 1 × 2
#> `"DRIVER"` TIME
#> <chr> <int>
#> 1 DRIVER 18014