| counts | R Documentation |
Use FARS or GES/CRSS data to generate commonly requested counts.
counts(
df,
what = c("crashes", "fatalities", "injuries", "people")[1],
interval = c("year", "month")[1],
where = list(states = "all", region = c("all", "ne", "mw", "s", "w")[1], urb = c("all",
"rural", "urban")[1]),
who = c("all", "drivers", "passengers", "bicyclists", "pedestrians")[1],
involved = c("any", "each", "alcohol", "bicyclist", "distracted driver", "drugs",
"hit and run", "large trucks", "motorcycle", "older driver", "pedalcyclist",
"pedbike", "pedestrian", "police pursuit", "roadway departure", "rollover",
"speeding", "young driver")[1],
filterOnly = FALSE
)
df |
The input data object (must be of class 'FARS' or 'GESCRSS' as is produced by get_fars() and get_gescrss()). |
what |
What to count: crashes (the default), fatalities, injuries, or people involved. |
interval |
The interval in which to count: months or years (the default). |
where |
Where to count. Must be a list with any of the elements: states (can be 'all', full or abbreviated state names, or FIPS codes), region ('all', 'ne', 'mw', 's', or 'w'; short for northeast, midwest, south, and west), urb ('all', 'rural', or 'urban'). Any un-specified elements are set to 'all' by default. |
who |
The type of person to count: 'all' (default) 'drivers', 'passengers', 'pedestrians', or 'bicyclists'. |
involved |
Factors involved with the crash: 'any' (the default, produces general counts), 'each' (produces separate counts for each factor), 'distracted driver', 'police pursuit', 'motorcycle', 'pedalcyclist', 'bicyclist', 'pedestrian', 'pedbike', 'young driver', 'older driver', 'speeding','alcohol', 'drugs', 'hit and run', 'roadway departure', 'rollover', or 'large trucks'. |
filterOnly |
Logical, whether to only filter data or reduce to counts (FALSE by default). |
Either a filtered tibble (filterOnly=TRUE) or a tibble of counts (filterOnly=FALSE). If filterOnly=TRUE, the tibble that is returned is the 'flat' tibble from the input FARS object, filtered according to other parameters.
If 'df' is a GESCRSS object, the counts returned are the sum of the appropriate weights.
## Not run:
counts(get_fars(years = 2019), where = list(states="Virginia", urb="rural"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.