Read in stats19 road safety data from .csv files downloaded.
Usage
read_vehicles(
year = NULL,
filename = "",
data_dir = get_data_directory(),
format = TRUE
)
Arguments
- year
Single year for which data are to be read
- filename
Character string of the filename of the .csv to read, if this is given, type and years determine whether there is a target to read, otherwise disk scan would be needed.
- data_dir
Where sets of downloaded data would be found.
- format
Switch to return raw read from file, default is
TRUE
.
Details
The function returns a data frame, in which each record is a reported vehicle in the STATS19 dataset for the data_dir and filename provided.
Examples
# \donttest{
if(curl::has_internet()) {
dl_stats19(year = 2019, type = "vehicle")
ve = read_vehicles(year = 2019)
}
#> Files identified: dft-road-casualty-statistics-vehicle-2019.csv
#> https://data.dft.gov.uk/road-accidents-safety-data/dft-road-casualty-statistics-vehicle-2019.csv
#> Attempt downloading from: https://data.dft.gov.uk/road-accidents-safety-data/dft-road-casualty-statistics-vehicle-2019.csv
#> Data saved at /tmp/RtmpzRqDGf/dft-road-casualty-statistics-vehicle-2019.csv
#> Rows: 216381 Columns: 28
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (4): accident_index, accident_reference, generic_make_model, lsoa_of_dr...
#> dbl (24): accident_year, vehicle_reference, vehicle_type, towing_and_articul...
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# }