Calculate speeding rate from the naturalistic data
nds_calc_speeding.Rdnds_calc_speeding extracts the speeding rate from the
naturalistic data
Arguments
- data
Object with naturalistic data (tibble or sf)
- type
Character with the type of speeding results ("time" or "distance")
- by
A column name to group the results
- spd
Numeric value of the speeding threshold
- exp
Numeric value of the exposure threshold
- percentage
Boolean value establishing if thresholds are percentages (TRUE or FALSE)
Details
This function uses the naturalistic data as main
input and extracts the speeding rate , grouping the results by the
attributes of the desired variable (parameter by). If type is
set to "distance", data must be a sf object with linestring geometry.
Otherwise, it can be a tibble or data.frame. spd and exp sets
two thresholds to identify exposure and speeding situations, based on the
performed speeds and speed limits. If percentage is TRUE, these
thresholds are set as percentages of the speed limit.
Examples
path <- system.file("extdata", package = "ndsbr")
nds_data <- 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_speeding(nds_data, type = "time", by = ID, spd = 5, exp = 10)
#> # A tibble: 9 × 2
#> # Groups: ID [9]
#> ID SP
#> <chr> <dbl>
#> 1 A05 0.302
#> 2 A12 0.303
#> 3 A18 0.075
#> 4 B08 0.105
#> 5 B13 0.422
#> 6 B18 0.379
#> 7 C04 0.273
#> 8 C07 0.418
#> 9 C13 0.505