-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a data dictionary and update README to document it
- Loading branch information
1 parent
19bc856
commit 388f278
Showing
6 changed files
with
287 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ cache/ | |
*.rds | ||
*.zip | ||
*.csv | ||
!docs/data-dict.csv | ||
*.xlsx | ||
!condo_nonlivable_demo.xlsx | ||
*.xlsm | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env Rscript | ||
# Script to check that the data dictionary file is up to date with the | ||
# latest feature set | ||
library(yaml) | ||
|
||
params_filename <- "params.yaml" | ||
data_dict_filename <- "docs/data-dict.csv" | ||
|
||
params <- read_yaml(params_filename) | ||
data_dict <- read.csv(data_dict_filename) | ||
|
||
symmetric_diff <- c( | ||
setdiff(data_dict$variable_name, params$model$predictor$all), | ||
setdiff(params$model$predictor$all, data_dict$variable_name) | ||
) | ||
symmetric_diff_len <- length(symmetric_diff) | ||
|
||
if (symmetric_diff_len > 0) { | ||
err_msg_prefix <- ifelse(symmetric_diff_len == 1, "Param is", "Params are") | ||
err_msg <- paste0( | ||
err_msg_prefix, | ||
" not present in both ", | ||
params_filename, | ||
" and ", | ||
data_dict_filename, | ||
": ", | ||
paste(symmetric_diff, collapse = ", "), | ||
". ", | ||
"Did you forget to reknit README.Rmd after updating ", | ||
params_filename, | ||
"?" | ||
) | ||
stop(err_msg) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.