Guest User

Untitled

a guest
Mar 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. set.seed(1234)
  2. M = matrix(sample(20,20), ncol=4)
  3. M
  4. [,1] [,2] [,3] [,4]
  5. [1,] 3 10 7 9
  6. [2,] 12 1 5 17
  7. [3,] 11 4 20 16
  8. [4,] 18 8 15 19
  9. [5,] 14 6 2 13
  10. t(apply(M, 1, function(x) head(order(x),3)))
  11. [,1] [,2] [,3]
  12. [1,] 1 3 4
  13. [2,] 2 3 1
  14. [3,] 2 1 4
  15. [4,] 2 3 1
  16. [5,] 3 2 4
Add Comment
Please, Sign In to add comment