I would to pick out any variable with ## in each row then store such variables in the vars_extract variable. Any idea?
library(tidyverse)
df <- tibble(
"a1" = c("##", 3, NA, 4, 5),
"a2" = c(10, 38, "##", 4, 5),
"a3" = c(11, 34, NA, 4, 5),
"a4" = c("##", 35, 67, 4, "##"),
"fname" = c("Megan", "John", "Terry", "Kim", "Anne")
)
# Trial (though not modified)
df %>%
mutate(vars_extract = names(.))
I would like to something like this
for Anne, I have vars_extract as "a1, a4"