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

Automatically add total_codes for OGD Data #28

Closed
GregorDeCillia opened this issue Mar 23, 2022 · 1 comment · Fixed by #23
Closed

Automatically add total_codes for OGD Data #28

GregorDeCillia opened this issue Mar 23, 2022 · 1 comment · Fixed by #23
Assignees
Labels
Milestone

Comments

@GregorDeCillia
Copy link
Contributor

GregorDeCillia commented Mar 23, 2022

The classification files of OGD datasets contain an optional column "FK" (Foreign Key) which can point to the parent element of the clasification element. This allows a definition of hierarchical classifications. Currently, the FK column is ignored by STATcubeR but it could be used to automatically detect "total codes". Example:

Code Name FK
WEST Label for West TOTAL
EAST Label for East TOTAL
TOTAL Label for Total

Here, there is a singe classification element (Code: TOTAL) and all other elements point to that element via FK. In cases like this, it is reasonable to regard TOTAL as the total code for this classification.

GregorDeCillia added a commit that referenced this issue Mar 29, 2022
for open data datasets, the FK-column
which can hold information about the
id of the parent element is now included
in the utput of the $field() method

part of #28
@GregorDeCillia
Copy link
Contributor Author

GregorDeCillia commented Mar 29, 2022

STATcubeR now automatically sets the total code if there is exactly one empty entry in the FK column. This issue will be closed as soon as #23 is merged

STATcubeR/R/od_utils.R

Lines 10 to 16 in fb58c48

od_get_total_code <- function(code, parent) {
if (sum(is.na(parent)) == 1) {
code[which(is.na(parent))]
} else {
NA_character_
}
}

@GregorDeCillia GregorDeCillia linked a pull request Aug 27, 2022 that will close this issue
5 tasks
@GregorDeCillia GregorDeCillia added this to the Version 1.0 milestone Aug 28, 2022
@GregorDeCillia GregorDeCillia self-assigned this Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant