From 8a11e8df125e66408c60afc58b09f797952acb9c Mon Sep 17 00:00:00 2001 From: Andrea Gilardi Date: Tue, 20 Jul 2021 19:55:27 +0200 Subject: [PATCH 1/2] rename f -> f2 since it's a nightmare to debug with a variable named f --- R/dl.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/dl.R b/R/dl.R index b1c64bc..2921a0a 100644 --- a/R/dl.R +++ b/R/dl.R @@ -120,10 +120,10 @@ dl_stats19 = function(year = NULL, utils::download.file(zip_url, destfile = destfile, quiet = silent) } if(is_zip_file) { - f = file.path(destfile, utils::unzip(destfile, list = TRUE)$Name) + f2 = file.path(destfile, utils::unzip(destfile, list = TRUE)$Name) utils::unzip(destfile, exdir = file.path(data_dir, exdir)) if (isFALSE(silent)) { - message("Data saved at ", sub(".zip", "",f)) + message("Data saved at ", sub(".zip", "", f2)) } } else if (isFALSE(silent)) { message("Data saved at ", destfile) From 23e61a162214adfe749492f2ae6b7f5cec0f940c Mon Sep 17 00:00:00 2001 From: Andrea Gilardi Date: Tue, 20 Jul 2021 23:33:32 +0200 Subject: [PATCH 2/2] use old readr on windows see #205 --- R/read.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/R/read.R b/R/read.R index aabdb85..8894f94 100644 --- a/R/read.R +++ b/R/read.R @@ -27,6 +27,12 @@ read_accidents = function(year = NULL, data_dir = get_data_directory(), format = TRUE, silent = FALSE) { + # Set the local edition for readr. + # See https://github.com/ropensci/stats19/issues/205 + if (.Platform$OS.type == "windows" && utils::packageVersion("readr") >= "2.0.0") { + readr::local_edition(1) + } + path = check_input_file( filename = filename, type = "accidents", @@ -163,6 +169,12 @@ check_input_file = function(filename = NULL, # path = file.path(get_data_directory(), f) # read_ve_ca(path) read_ve_ca = function(path) { + # Set the local edition for readr. + # See https://github.com/ropensci/stats19/issues/205 + if (.Platform$OS.type == "windows" && utils::packageVersion("readr") >= "2.0.0") { + readr::local_edition(1) + } + h = utils::read.csv(path, nrows = 1) if(grepl("Accident_Index", names(h)[1])) { readr::read_csv(path, col_types = readr::cols(