I have a question related to matrix().

The code below randomly generates 3 Poisson numbers into a 3 by 1 matrix:

> matrix1 <- matrix(rpois(3,lambda=2),nrow=3,ncol=1)

And I use list() to see what they are:

     [,1]

[1,]  3

[2,]  1

[3,]  4

, which is what I had intended.

I then I want to randomly generate y Normal numbers into a 3 by 8 matrix. y in this 
case would be 3, 1, and 4; so the resulting matrix should be such that the first row 
has three different Normal numbers; the second row has 1 Normal number; and the third 
row has four different Normal numbers. I have the following code to do that:

> matrix2 <- matrix(rnorm(poisNums),nrow=3,ncol=8)

To my surprise, matrix2 does not look anything like what I had intended. Instead, it 
repeats the values in the first column (of the matrix2) eight times. What part of the 
code do I need to fix?


        [[alternative HTML version deleted]]

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to