nds_calc_speeding: Calculate speeding rate from the naturalistic data

View source: R/nds_calc.R

nds_calc_speedingR Documentation

Calculate speeding rate from the naturalistic data

Description

nds_calc_speeding extracts the speeding rate from the naturalistic data

Usage

nds_calc_speeding(data, type, by, spd, exp, percentage = FALSE)

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.

Value

A tibble with speeding rate results

Examples

path <- system.file("extdata", package = "ndsbr")
nds_data <- nds_load_data("driver", path)
nds_calc_speeding(nds_data, type = "time", by = ID, spd = 5, exp = 10)

pabsantos/ndsbr documentation built on June 13, 2024, 3:47 a.m.