Coalesce survey responses in a dataframe

Why not to do something like this?

Q1 <- c(NA, NA, "A", NA, NA)
#> [1] "A"

It would be easier to help you if you could provide a minimal REPRoducible EXample (reprex).

EDIT: Just in case you still want to follow the regex path

str_extract(paste("A",NA,NA,NA,NA), "(?<!N\\s?)[A-E]")
#> [1] "A"
1 Like