ccb-hms/phonto

unionQuery

Closed this issue · 3 comments

unionQuery(tb_names, cols = NULL)

one of the challenges this poses is that the tables might not have the same variables across all years, and then
even if they do, they might not have the same codebooks across all years

we might want a design that does a bit more testing - eg a function called sameVars that takes a list of nhanes Questionnaire names and tells you if they have the same columns. Another function called say sameCodeBook - that compares the code books and here I think you might want to split up the output
nhanesCodebook('DEMO_D', 'RIAGENDR')
$Variable
[1] "RIAGENDR"

$Description
[1] "Gender of the sample person"

$Target
[1] "Both males and females 0 YEARS - 150 YEARS"

$SasLabel
[1] "Gender"

$RIAGENDR
Variable CodeOrValue ValueDescription Count Cumulative SkipToItem
1 RIAGENDR 1 Male 5080 5080 NA
2 RIAGENDR 2 Female 5268 10348 NA
3 RIAGENDR . Missing 0 10348 NA

And test if variable, description, target and saslabel are the same,
then within the codebook itself, we need to know if the values are the same, and if the valueDescriptions are the same.
For example it would be bad if there was some RIAGENDR table where 1 was Female and 2 was Male ....we hope they never did that, but we probably have to protect against it

oh - and I think from a design decision point of view, it might be best to do nhanesTranslate on the tables prior to the merge
my feeling is that that way we are really merging on the actual data (not the codes that NHANES uses).

I agree, but we may need users to specify the columns are needed to be translated. We may not want to translate the continuous variables.

With the translated DB and new phonto, the issue has been solved.