Skip to content

Commit ad4154d

Browse files
committed
set answer code 13 to NA before checking if col is all NA
1 parent 9394955 commit ad4154d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

facebook/delphiFacebook/R/variables.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,8 @@ code_vaccines <- function(input_data, wave) {
646646
# If the entire column is NA, ifelse() results in a logical vector, not a
647647
# character vector, which confuses split_options; since the result should be
648648
# NA anyway
649+
vaccine_barriers <- ifelse(vaccine_barriers == "13", NA_character_, vaccine_barriers)
649650
if (any(!is.na(vaccine_barriers))) {
650-
vaccine_barriers <- ifelse(vaccine_barriers == "13", NA_character_, vaccine_barriers)
651651
vaccine_barriers <- split_options(vaccine_barriers)
652652
}
653653

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

0 commit comments

Comments
 (0)