Skip to content

Conversation

@nmdefries
Copy link
Contributor

Description

Followup to #1346. Set answer code 13 to NA before checking if col is all NA.

Changelog

  • variables.R

Fixes

In rare cases, vaccine_barriers <- ifelse(vaccine_barriers == "13", NA, vaccine_barriers) or vaccine_barriers <- ifelse(input_data$V15b == "13", NA, input_data$V15b) will make a column all NA when it wasn't before. This happens when the only non-NA responses have answer code "13".

@nmdefries nmdefries requested a review from krivard December 19, 2021 19:09
@nmdefries
Copy link
Contributor Author

@capnrefsmmat FYI. I'm thinking the more robust fix is to change split_options to return a list of NA if given a column of all NA. I don't think that messes up any of our other logic, but that'll need a more careful look and more code changes, so I'll do it in a separate PR.

Comment on lines 649 to 650
vaccine_barriers <- ifelse(vaccine_barriers == "13", NA_character_, vaccine_barriers)
if (any(!is.na(vaccine_barriers))) {
vaccine_barriers <- ifelse(vaccine_barriers == "13", NA_character_, vaccine_barriers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the entire column is NA, and (thus) ifelse() results in a logical vector, how does that affect any(!is.na(vaccine_barriers))?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is.na appears to have the same behavior for logical NA and character missing (NA_character_), but I'll explicitly cast to character to be safe. The downstream is_selected also appears to work correctly with logical NA but expects strings.

Copy link
Contributor

@krivard krivard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants