Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. v1 = c(1,3,2,4,1)
  2. v2 = c(2,2,2,2,2)
  3. dados = matrix(c(v1,v2),ncol = 2)
  4. N = ncol(dados)
  5. n = nrow(dados)
  6. nBS <- 5
  7.  
  8. for (i in 1:N){
  9. y = dados[,i]
  10. lst <- lapply(1:N, function(x) matrix(sample(y,n,T), nrow = n, ncol = nBS))
  11. }
  12.  
  13. > lst
  14. [[1]]
  15. [,1] [,2] [,3] [,4] [,5]
  16. [1,] 2 2 2 2 2
  17. [2,] 2 2 2 2 2
  18. [3,] 2 2 2 2 2
  19. [4,] 2 2 2 2 2
  20. [5,] 2 2 2 2 2
  21.  
  22. [[2]]
  23. [,1] [,2] [,3] [,4] [,5]
  24. [1,] 2 2 2 2 2
  25. [2,] 2 2 2 2 2
  26. [3,] 2 2 2 2 2
  27. [4,] 2 2 2 2 2
  28. [5,] 2 2 2 2 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement