Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. [,1] [,2]
  2. [1,] 1 2
  3. [2,] 3 4
  4. [3,] 5 6
  5.  
  6. [,1] [,2] [,3] [,4] [,5] [,6]
  7. [1,] 1 1 1 2 2 2
  8. [2,] 3 3 3 4 4 4
  9. [3,] 5 5 5 6 6 6
  10.  
  11. mat[,rep(seq_len(ncol(mat)), each=3)]
  12. # [,1] [,2] [,3] [,4] [,5] [,6]
  13. # [1,] 1 1 1 2 2 2
  14. # [2,] 3 3 3 4 4 4
  15. # [3,] 5 5 5 6 6 6
  16.  
  17. (mat <- matrix(1:6, nrow=3, byrow = TRUE))
  18. # [,1] [,2]
  19. # [1,] 1 2
  20. # [2,] 3 4
  21. # [3,] 5 6
  22.  
  23. k =3
  24. matrix(rep(mat, each = k), ncol = ncol(mat) * k, byrow = TRUE)
  25.  
  26. # [,1] [,2] [,3] [,4] [,5] [,6]
  27. #[1,] 1 1 1 3 3 3
  28. #[2,] 5 5 5 2 2 2
  29. #[3,] 4 4 4 6 6 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement