ropensci/stats19

Error downloading data for 2015

Closed this issue · 3 comments

Seeing this error for 2015, generated by copying the code in the commit below with Ctrl+C and then entering the command reprex::reprex() in the R console:

# Aim: test 2015 data
remotes::install_github("ropensci/stats19")
#> Using github PAT from envvar GITHUB_PAT
#> Skipping install of 'stats19' from a github remote, the SHA1 (0b29adca) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(stats19)
#> Data provided under OGL v3.0. Cite the source and link to:
#> www.nationalarchives.gov.uk/doc/open-government-licence/version/3/
# ?get_stats19
crashes_2017 = get_stats19(2017, type = "accident")
#> Files identified: dft-road-casualty-statistics-accident-2017.csv
#>    https://data.dft.gov.uk/road-accidents-safety-data/dft-road-casualty-statistics-accident-2017.csv
#> Data already exists in data_dir, not downloading
#> Data saved at /data/stats19/dft-road-casualty-statistics-accident-2017.csv
#> Reading in:
#> /data/stats19/dft-road-casualty-statistics-accident-2017.csv
#> Rows: 129982 Columns: 36
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr   (8): accident_index, accident_reference, longitude, latitude, date, lo...
#> dbl  (27): accident_year, location_easting_osgr, location_northing_osgr, pol...
#> time  (1): time
#> 
#> ℹ 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.
#> date and time columns present, creating formatted datetime column
crashes_2015 = get_stats19(2015, type = "accident")
#> No files of that type found for that year.
#> No files found. Check the stats19 website on data.gov.uk
#> Files identified: 
#> 
#> 
#> Error in if (is_zip_file) {: argument is of length zero

Created on 2022-11-27 with reprex v2.0.2

layik commented

Just to say that above issue is there (in CRAN 2.0.1). Also stats19 CRAN 2.0.1 fails for 2021 & 2022. I have a feeling this is due to the change of either location or format of files by DfT, if this is the case we had anticipated this when we built the package. Would welcome contributors as I am tied up and looks like other contributors are too.

library(stats19)
#> Data provided under OGL v3.0. Cite the source and link to:
#> www.nationalarchives.gov.uk/doc/open-government-licence/version/3/
get_stats19(year = 2021, type = "acc")
#> No files of that type found for that year.
#> No files found. Check the stats19 website on data.gov.uk
#> Files identified:
#> 
#> Error in if (is_zip_file) {: argument is of length zero
get_stats19(year = 2022, type = "acc")
#> No files of that type found for that year.
#> No files found. Check the stats19 website on data.gov.uk
#> Files identified:
#> 
#> Error in if (is_zip_file) {: argument is of length zero
packageVersion("stats19")
#> [1] '2.0.1'

Created on 2023-09-18 with reprex v2.0.2

layik commented

Hi @Robinlovelace et al.

Seeing this error for 2015

I had a look at https://www.data.gov.uk/dataset/cb7ae6f0-4be6-4935-9277-47e5ce24a11f/road-safety-data and there is no 2015 therefore our data-raw/misc.R fails to update the file names (as it should). See image pasted. It cannot find the 2011-2015 as file name does not include 2015 and is not available: relevant URL is https://data.dft.gov.uk/road-accidents-safety-data/DfTCasualtyDashboard.zip

image

It's been deleted so let's remove that bit of code.