Skip to content

Fix pipeline when barrier column is all NAs part 2 #1435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 19, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions facebook/delphiFacebook/R/variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,8 @@ code_vaccines <- function(input_data, wave) {
# If the entire column is NA, ifelse() results in a logical vector, not a
# character vector, which confuses split_options; since the result should be
# NA anyway
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.

vaccine_barriers <- split_options(vaccine_barriers)
}

Expand Down Expand Up @@ -786,8 +786,8 @@ code_vaccines <- function(input_data, wave) {
# If the entire column is NA, ifelse() results in a logical vector, not a
# character vector, which confuses split_options; since the result should be
# NA anyway
if (any(!is.na(input_data$V15b))) {
vaccine_barriers <- ifelse(input_data$V15b == "13", NA, input_data$V15b)
vaccine_barriers <- ifelse(input_data$V15b == "13", NA, input_data$V15b)
if (any(!is.na(vaccine_barriers))) {
vaccine_barriers <- split_options(vaccine_barriers)
} else {
vaccine_barriers <- input_data$V15b
Expand Down