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

Translate data sqids #34

Merged
merged 17 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export(get_meta_response)
export(get_publications)
export(http_request_error)
export(parse_api_dataset)
export(parse_data_squids)
export(parse_filter_in)
export(parse_meta_filter_columns)
export(parse_meta_filter_item_ids)
Expand Down
26 changes: 26 additions & 0 deletions R/parse_data_squids.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#' Parse IDs in returned API data
#'
#' @description
#' The API uses unique IDs (squids) to identify each filter column, filter_item and indicator column.
Fixed Show fixed Hide fixed
#' This facilitates continuity, i.e. data creators may need to change the col_name and labeling in
#' their data files, whilst maintaining the same fundamental content. Results from the API are given
#' using these IDs, but it's expected that analysts will want to translate these back into the
#' col_names assigned by analysts. `parse_data_squids()` takes a data frame extracted from the API
#' and translates all the squids in that data frame to their assigned col_names based on the meta
#' data available from the API.
#'
#' @param data Data frame containing data as returned from the API by `get_dataset()` or
#' `post_dataset()`
#' @param datatset_id String containing the data set ID
#'
#' @return Data frame
#' @export
#'
#' @examples
#' get_dataset(example_id(), indicators = example_id("indicator"), page = 1) |>
#' parse_data_squids(example_id())
parse_data_squids <- function(
data,
datatset_id) {
meta <- get_meta(dataset_id)
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
}
30 changes: 30 additions & 0 deletions man/parse_data_squids.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading