Closed DanielEWeeks closed 1 year ago
This issue has been resolved with the following modification/addition related to DD.cols <- tb %>% filter(.data$VALUE == code)
line mentioned above:
# Find columns in the data dictionary that specify a value for the given code
if (is.na(code)) { # Change to resolve issue #10 making this search conditional upon code being NA or non-NA
DD.cols <- tb %>%
filter(.data$VALUE=="NA")
} else {
DD.cols <- tb %>%
filter(.data$VALUE==code)
}
Incidentally when investigating this error, I also discovered that the column names in ExampleS were not correct (X.SUBJECT_ID
vs. SUBJECT_ID
, etc.). I have now corrected this.
In the 8/14 version of the 2017-2019 Samoan data,
missing_value_check
flags some variables even though they properly haveNA=N/A
in their firstVALUES
column.I think it isn't working because the
NA=N/A
is mapped by thevalue_meaning_table
function to aVALUE
of "NA" (a character string) instead of to aNA
(R missing value code), but then this line is setting up to check for theNA
R missing value code:Oh, but
codes
is used with theNA
R missing value code to find those columns in the data that contain at least oneNA
via this line:But then if the
code
isNA
, then the next line after them.cols
line is this:When the
code
isNA
, this does not find any such columns because in thetb
, theNA
is instead the character string"NA"
.If I instead do
then I do find all the columns that have a
NA=N/A
VALUES=MEANING mapping.So maybe the solution here is to have two parallel
codes
:codes <- c(NA, unique(na.omit(non.NA.missing.codes)))
tb
table of VALUES and MEANINGScodes_str <- c("NA", unique(na.omit(non.NA.missing.codes)))