-
Notifications
You must be signed in to change notification settings - Fork 18
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
changes relating to issue 237 #238
Conversation
… file that is already on the local disk. seperate read_in functions for each type have been replaced with only the format function as the file path is already defined from dl_stats19 get_url and get_data_directory belong in the get module?
…user replaced if(interactive) with isTRUE(ask) to enable the user to decide for the request not to be interupted (ask was not used) changed the default file to the second, which matches other years added the destination file as the return from the function
…bugging replaced the pattern to 1979 and not the request year as it is one file for all periods before 2016 files_on_disk function amended to use list.files
@@ -47,7 +26,7 @@ find_file_name = function(years = NULL, type = NULL) { | |||
result = result[!grepl(pattern = "1979", x = result)] | |||
} | |||
result = result[!grepl(pattern = "adjust", x = result)] | |||
result = result[grepl(pattern = years, x = result)] | |||
result = result[grepl(pattern = "1979", x = result)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to that, although will it still work for non 1979 (all) years? I guess so but would need to test..
#' Get data download dir | ||
#' @examples | ||
#' # get_data_directory() | ||
get_data_directory = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to moving everything into a more accessible place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK tests failing. Will investigate..
Am not so familiar with the package testing, but have moved get_url test to test-get and run the testthat.R script (didn't do that before) and it passes with only warnings (on windows). |
changed output to read_in after formatting (or not) to be consistent with previous code
…. It also appeared to be missing an else, so have changed to be explicit for specific years.
Hey @BlaiseKelly I've checked out your branch and had a look but no luck, as you say lots of changes. Would be able to resubmit a more focussed PR, or we can set-up a call to double team this and you can talk me through the changes. There are definitely issues with the code, I think we could remove many lines and make the package better, especially now DfT datasets are simpler. However, this PR actually adds more lines than it removes due to rendered HTML. Really keen to get your changes in in any case, just a question of working out how. |
Ps. these are the errors I get when running
|
The README and html were added later to my branch. I didn't intend to push them to the main. |
It seems to be related to the locate_file functions which are difficult to debug as there are so many nested functions.
However, the dl_stats19 function either downloads the data or identifies the file in the local directories. Either way the directory of the data is known by the end of this function. So it maybe simplifies things if this just returns the full path of the one file that is being requested (only one year or type is allowed to be requested at any one time). This also negates many of the read functions.
There was a bug in the locate_files functions which was preventing multiple files from being returned for 2020. This amendment changes the dl_stats19 function to return the file path of either the downloaded file or the file already in the local folder. This bypasses the locate_file and read_in functions.
In the same function changed the default file to be returned if ask is FALSE to be the second file returned and not the e-scooter.
I was also getting errors importing earlier files as it seemed to be searching for a file with the year, however it appears all years prior to 2017 are stored in a single file named "1979".
A few other minor changes which hopefully won't cause any other issues with other functions