[R] error in sample ()

Silvia Lomascolo slomascolo at zoo.ufl.edu
Wed Oct 17 00:53:41 CEST 2007


I am trying to get a random matrix based on an original matrix called
disperser.mx, with dimensions 30x73

When I write the following code:

>scramble = sample (disperser.mx)
>newmat = matrix(scramble, nrow=30)

I get the following warning message and a very weird matrix with 30 rows but
only 3 columns shown below:

Warning message:
data length [73] is not a sub-multiple or multiple of the number of rows
[30] in matrix in: matrix(scramble, nrow = 30)

     [,1]       [,2]       [,3]      
 [1,] Integer,30 Integer,30 Integer,30
 [2,] Integer,30 Integer,30 Integer,30
 [3,] Integer,30 Integer,30 Integer,30
 [4,] Integer,30 Integer,30 Integer,30
 [5,] Integer,30 Integer,30 Integer,30
 [6,] Integer,30 Integer,30 Integer,30
 [7,] Integer,30 Integer,30 Integer,30
 [8,] Integer,30 Integer,30 Integer,30
 [9,] Integer,30 Integer,30 Integer,30
...

Can anyone please help me figure out why I get such a weird result?
-- 
View this message in context: http://www.nabble.com/error-in-sample-%28%29-tf4637263.html#a13244007
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list