Guest User

Untitled

a guest
Jan 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. library(dplyr)
  2.  
  3. df <- data.frame(grp_A = c(13, NA, NA, NA, NA, 20, NA),
  4. grp_B = c(NA, 59, 66, NA, NA, NA, NA),
  5. grp_C = c(NA, NA, NA, 23, 42, NA, NA))
  6.  
  7. df$value <- apply(select(df, grp_A, grp_B, grp_C), 1,
  8. function(x) x[!is.na(x)])
Add Comment
Please, Sign In to add comment