Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(dplyr)
- df <- data.frame(grp_A = c(13, NA, NA, NA, NA, 20, NA),
- grp_B = c(NA, 59, 66, NA, NA, NA, NA),
- grp_C = c(NA, NA, NA, 23, 42, NA, NA))
- df$value <- apply(select(df, grp_A, grp_B, grp_C), 1,
- function(x) x[!is.na(x)])
Add Comment
Please, Sign In to add comment