Read in STATS19 road safety data from .csv files downloaded.

read_accidents(year = NULL, filename = "", data_dir = tempdir(),
  format = TRUE)



Single year for which data are to be read


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.


Where sets of downloaded data would be found.


Switch to return raw read from file, default is TRUE.


This is a wrapper function to access and load stats 19 data in a user-friendly way. The function returns a data frame, in which each record is a reported incident in the STATS19 data.


dl_stats19(year = 2011, type = "Accidents")
#> Files identified:
#> Attempt downloading from:
#> Data saved at /tmp/RtmpGajYm7/DfTRoadSafety_Accidents_2011/DfTRoadSafety_Accidents_2011.csv
ac = read_accidents(year = 2011)
#> Reading in:
#> /tmp/RtmpGajYm7/DfTRoadSafety_Accidents_2011/DfTRoadSafety_Accidents_2011.csv
dl_stats19(year = 2009, type = "Accidents")
#> Files identified:
#> Data already exists in data_dir, not downloading
#> Data saved at /tmp/RtmpGajYm7/DfTRoadSafety_Accidents_2009/DfTRoadSafety_Accidents_2009.csv
ac_2009 = read_accidents(year = 2009)
#> Reading in:
#> /tmp/RtmpGajYm7/DfTRoadSafety_Accidents_2009/DfTRoadSafety_Accidents_2009.csv