Using the dplyr library in R to “print” the name of the non-NA columns
6
Here is my data frame: a <- data.frame(id=c(rep("A",2),rep("B",2)), x=c(rep(2,2),rep(3,2)), p.ABC= c(1,NA,1,1), p.DEF= c(NA,1,NA,NA), p.TAR= c(1,NA,1,1), p.REP= c(NA,1,1,NA), p.FAR= c(NA,NA,1,1)) I Want to create a new character column (using mutate() in the dplyr library in R), which tells (by row) the name of the columns that have a non-NA value (here the non-NA value is always 1). However, it should only search among the columns that start with "p." and it should order the names by alphabetical order and then concatenate them using the expression "_" as a separator. You can find below the desired result, under the column cal...