-
Notifications
You must be signed in to change notification settings - Fork 94
Add statistics functions #836
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
base: develop
Are you sure you want to change the base?
Conversation
R/read_waterdata_stats_datatable.R
Outdated
| combined <- data.table::rbindlist(combined_list) | ||
| combined <- combined[return_list, on = "rid"] | ||
|
|
||
| col_order <- c("parent_time_series_id", "monitoring_location_id", "monitoring_location_name", "parameter_code", |
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.
Ideally we can figure out a way to not write these out by hand. On the off-chance they add some columns or change the function will start to fail. (and yes, similar hard-coding has caused some headaches in the past with dataRetrieval). We added some logic (I think just in the current PR that removes max_results) to move all "id" columns to the far right (because users don't want to see those big ol'hashes first) UNLESS they are special like monitoring_location_id.
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 column order is no longer hard-coded in the function, but I don't think the current order we get from unpacking the nested JSON is ideal:
c("parameter_code", "unit_of_measure", "parent_time_series_id",
"value", "percentile", "sample_count", "approval_status", "computation_id",
"computation", "time_of_year", "time_of_year_type", "monitoring_location_id",
"monitoring_location_name", "site_type", "site_type_code", "country_code",
"state_code", "county_code", "geometry") I can merge the newest changes into this branch to see if what you mentioned changes anything. Otherwise, what would you recommend?


Still to-do:
get_params,get_description, andbase_urlfunctions to pull the docs for /statistics too?get_statistics_datainto separate functions to match other read_waterdata patternsread_ogc_datahelpers are needed:return_list <- do.call(rbind, return_list_tmp)as it's a slight bottleneck.And there's Laura's list of to-dos here: https://code.usgs.gov/water/dataRetrieval/-/issues/450