Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few fixes for some issues #244

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

BlaiseKelly
Copy link

swapped interactive with ask (which was not used) which is v important to be able to leave code running without being prompted.

Changed default file to second. The only year where two csvs are available is 2020 and for escooter data. Maybe this is interesting for some, but the other file should be the default.

returning destfile works better for dependent functions

get.R

main change is to skip the read_ functions which involve multiple nested functions appear to be unneccesary and are a headache to debug.

utils.R

Main change is to fix find_file_name function which was looking for a csv with year name for years before 2018. This data is all in one file which has 1979 in.

swapped interactive with ask (which was not used) which is v important to be able to leave code running without being prompted.

Changed default file to second. The only year where two csvs are available is 2020 and for escooter data. Maybe this is interesting for some, but the other file should be the default.

returning destfile works better for dependent functions

get.R

main change is to skip the read_ functions which involve multiple nested functions appear to be unneccesary and are a headache to debug.

utils.R

Main change is to fix find_file_name function which was looking for a csv with year name for years before 2018. This data is all in one file which has 1979 in.
@Robinlovelace
Copy link
Member

Looking at this now Blaise...

@Robinlovelace
Copy link
Member

Hitting this issue with devtools::check():

@Robinlovelace
Copy link
Member

   Quitting from lines 82-83 [dl2022-accidents] (stats19.Rmd)
   Error: processing vignette 'stats19.Rmd' failed with diagnostics:
   could not find function "get_data_directory"

Copy link
Member

@Robinlovelace Robinlovelace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of comments for you @BlaiseKelly 🙏

#' Get data download dir
#' @examples
#' # get_data_directory()
get_data_directory = function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this? It's needed in other functions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I meant to move to get.R (as it took me a while to find where it was).
Have added to get.R

result = result[!grepl(pattern = "adjust", x = result)]
result = result[grepl(pattern = years, x = result)]
result = result[grepl(pattern = "1979", x = result)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

R/get.R Outdated
data_dir = data_dir,
format = format)
# read in from the file path defined above
if(grepl(type, "vehicles", ignore.case = TRUE)){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument of grepl() is pattern so shouldn't "vehicles" go before type?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite right! Have amended

Copy link
Member

@Robinlovelace Robinlovelace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

@@ -112,7 +112,7 @@ get_stats19 = function(year = NULL,
)
output_format = "tibble"
}
if (grepl(type, "casualties", ignore.case = TRUE) && output_format %in% c("sf", "ppp")) {
if (grepl("casualties", type, ignore.case = TRUE) && output_format %in% c("sf", "ppp")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (grepl("casualties", type, ignore.case = TRUE) && output_format %in% c("sf", "ppp")) {
if (grepl("cas", type, ignore.case = TRUE) && output_format %in% c("sf", "ppp")) {

And save for "veh" and "acc|col" so more things match.

@Robinlovelace
Copy link
Member

Thanks @BlaiseKelly almost there!

Please can you take a look at test-utils.R to see what's up? From the logs in the workflow it seems it's just that test that's failing now:

 Backtrace:
    ▆
 1. └─stats19::read_collisions(year = 2019) at test-read_stats19.R:19:3
 2.   ├─base::suppressWarnings(...) at stats19/R/read.R:49:3
 3.   │ └─base::withCallingHandlers(...)
 4.   └─readr::read_csv(path) at stats19/R/read.R:50:5
 5.     └─vroom::vroom(...)
 6.       └─vroom:::standardise_path(file)
 7.         └─cli::cli_abort(...)
 8.           └─rlang::abort(...)
── Failure ('test-utils.R:12:3'): find_file_name works ─────────────────────────
length(find_file_name(type = "coll")) > 5 is not TRUE

`actual`:   FALSE
`expected`: TRUE 
── Failure ('test-utils.R:15:3'): find_file_name works ─────────────────────────
`find_file_name(years = 1973)` did not produce any messages.

Source: https://github.com/ropensci/stats19/actions/runs/10091716542/job/27903832622?pr=244#step:6:260

Any ideas why?

@Robinlovelace Robinlovelace mentioned this pull request Jul 31, 2024
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants