jeudi 21 février 2019

Generate data matrix using the given data matrix in R

Suppose I have a 200 x 200 matrix using the following r function.

n = 200
sim.mat = matrix(NA, nrow = n, ncol = n)
 for (i in 1:n){
   sim.mat[,i] = c(rnorm(i, 2, 1), rnorm(n-i, 3, 1))
 }

How can I generate 200 x 1000matrix using the same c(rnorm(i, 2, 1), rnorm(n-i, 3, 1)) setting?

Thank you.




Aucun commentaire:

Enregistrer un commentaire