-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use CodeAndValue when overlaps are detected in any columns
Fixes #24
- Loading branch information
1 parent
a3ceb7a
commit ccd6d16
Showing
3 changed files
with
44 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#' Helper function to determine wether or not to include the id in a variable | ||
#' option | ||
#' | ||
#' @param meta_data Meta data object for the table of inquiry | ||
#' @noRd | ||
dst_determine_overlaps <- function(meta_data) { | ||
# Get variable names | ||
var_names <- get_vars(meta_data) | ||
|
||
# Get options for all variable names | ||
options <- get_var_options(meta_data, var_names) | ||
|
||
# Index over all vars to determine if there is duplicates | ||
dup <- list() | ||
|
||
for (i in seq_along(var_names)) { | ||
dup[i] <- length( | ||
options[[var_names[i]]] | ||
) == length( | ||
unique(options[[var_names[i]]]) | ||
) | ||
} | ||
|
||
# If any of the option/vars include duplicates, we should include the id | ||
return(any(unlist(dup))) | ||
} |
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,3 @@ | ||
test_that("Overlap detection works", { | ||
expect_true(dst_determine_overlaps(dst_meta("FV22TOTA"))) | ||
}) |