SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. df <- data.frame(v1 = c(0,1,2,3,4,5,6,7,8,9),
  2.                  v2 = c(2,1,4,7,6,7,8,9,0,1),
  3.                  v3 = c(4,1,6,7,8,9,0,1,2,3),
  4.                  v4 = c(0,1,2,7,4,5,6,7,8,9),
  5.                  v5 = c(0,1,6,3,6,9,8,9,0,1))
  6.      
  7. df$max <- colnames(df)[apply(df,1,which.max)]
  8.      
  9. v1 v2 v3 v4 v5 v1max v2max v3max v4max v5max
  10. 1   0  2  4  0  0 FALSE FALSE TRUE  FALSE FALSE
  11. 2   1  1  1  1  1 TRUE  TRUE  TRUE  TRUE  TRUE  
  12. 3   2  4  6  2  6 FALSE FALSE TRUE  FALSE TRUE    
  13. 4   3  7  7  7  3 FALSE TRUE  TRUE  TRUE  FALSE
  14. 5   4  6  8  4  6 FALSE FALSE TRUE  FALSE FALSE
  15. 6   5  7  9  5  9 FALSE FALSE TRUE  FALSE TRUE
  16. 7   6  8  0  6  8 FALSE TRUE  FALSE FALSE TRUE
  17. 8   7  9  1  7  9 FALSE TRUE  FALSE FALSE TRUE
  18. 9   8  0  2  8  0 TRUE  FALSE FALSE TRUE  FALSE
  19. 10  9  1  3  9  1 TRUE  FALSE FALSE TRUE  FALSE
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top