How to create new column with all non-NA values from multiple other columns?
问题 I would like to create a column d, which includes all the non-NA values from the other columns. I tried ifelse, but cannot figure out how to make it nested in the proper manner, so that the value in column c is included as well.. Perhaps something else than ifelse should be used? Here is a "dummy" dataframe: a <- c(NA, NA, NA, "A", "B", "A", NA, NA) b <- c("D", "A", "C", NA, NA, NA, NA, NA) c <- c(NA, NA, NA, NA, NA, NA, "C", NA) data <- data.frame(a, b, c) I would like the d column to look