-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add new functions #21
Conversation
#' @param cache_dir a path to cache directory. | ||
#' @param query_hash a character used to identify the data.frame. | ||
#' | ||
#' @references See citation("sotkanet") |
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.
@references tag should be used for the following purpose: "Use @references point to published material about the package that users might find helpful." Source: https://mpn.metworx.com/packages/roxygen2/7.1.0/articles/rd.html
Putting package citation in References is actually also used in the eurostat package so we should look into whether this is sensible thing to do
R/SotkanetInteractive.R
Outdated
capture.output(print( | ||
paste0("GetDataSotkanet(indicators = ", search_id, | ||
", years = ", years[1], ":", years[length(years)], | ||
", genders = ", gender_selection, ", regions = ", |
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.
gender_selection needs to be wrapped in single or double quotes. I got the following error when trying to re-run retrieval code printed here:
GetDataSotkanet(indicators = 10027, years = 2000:2015, genders = total, regions = NULL, region.category = NULL)
Error: object 'total' not found
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.
The function works nicely but there are still some hiccups:
- If I input region.category (and probably regions) without quotes, the function seems to accept this as valid but it still prints the download code without double quotes:
Enter the regions (empty for default):
Enter the region.category (empty for default): POHJOISMAAT
[...]
#### DOWNLOAD PARAMETERS:
[1] "get_sotkanet(indicators = 10027, years = 2000:2005, genders = c('male', 'female'), regions = NULL, region.category = POHJOISMAAT, lang = 'fi')"
This results in R searching for a variable called POHJOISMAAT, not string "POHJOISMAAT":
get_sotkanet(indicators = 10027, years = 2000:2005, genders = c('male', 'female'), regions = NULL, region.category = POHJOISMAAT, lang = 'fi')
Error: object 'POHJOISMAAT' not found
So I guess it's more about fine-tuning the example download string.
- I get this weird tooltip when I input data manually:
I wonder what causes it? It's obviously useless / misleading. Maybe it's from RStudio and not R?
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.
Then there's the hassle with selecting regions:
Enter the regions (empty for default): c("Suomi", "Ruotsi")
Enter the region.category (empty for default):
Input for regions not found from dataset: c("Suomi", "Ruotsi")
Please check your parameter input for validity and correctness.
In code for downloading data this input get mangled by extra escape-characters:
"get_sotkanet(indicators = 10027, years = 2000:2005, genders = c('male', 'female'), regions = c(\"Suomi\", \"Ruotsi\"), region.category = NULL, lang = 'fi')"
From the API documentation we see that we should be using region codes anyway for selecting regions, not names:
region
^\d+$
Alueen tunnus, jota käytetään SOTKAnetin ja sen APIn kutsuissa
For example Sweden is 1044 and Finland is 1045. It might be a good idea either to give a hint to end user on how to input multiple values: wrapped in c(), separated by comma...?
Enter the regions (empty for default): 1044, 1045
Enter the region.category (empty for default):
Input for regions not found from dataset: 1044, 1045
Please check your parameter input for validity and correctness.
#### DOWNLOAD PARAMETERS:
[1] "get_sotkanet(indicators = 10027, years = 2000:2005, genders = c('male', 'female'), regions = 1044, 1045, region.category = NULL, lang = 'fi')"
Maybe the most ideal solution would be to read all available options for each datasets from the metadata and print them using the language that the user chose in the first step. Then the user could select one or more regions, without having to care about Sotkanet region codes.
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.
One way would also be to remove regions and region.category selection since the filtering is done locally anyway
Tested with this:
I'm not entirely sure what causes this. Is it the |
The issue was that the |
Add functions SotkanetInteractive, SotkanetCleanCache and get_sotkanet. Also add helper functions sotkanet_read_cache, sotkanet_write_cache and write_frictionless_metadata.