Re: [R] problem creating an array

2012-09-13 Thread Bert Gunter
Well, Rui -- I'll bet that that gobSmacked him (and probably others)! So here's just a tiny extra effort at enlightenment. The keys are understanding that: 1. Matrices are (formally) just 2-d arrays. 2. All arrays are just vectors, indexed in "column major" order -- i.e. rows vary the fastest, th

Re: [R] problem creating an array

2012-09-13 Thread Rui Barradas
Hello, You don't need the loop, it can be done with one much simpler instruction. Since the number of rows is not important, the example uses a 10x603 matrix. x <- matrix(seq_len(10*603), ncol = 603) y <- array(x, dim = c(10, 3, 201)) # that's it # See the first two y[, , 1:2] Hope this helps

[R] problem creating an array

2012-09-13 Thread Curtis Burkhalter
Hello, I am having trouble creating a (1000,3,201) array in R from a data set created within the same script. My problem is that I want to take a matrix that is 1000x603 (called "landmat") and separate this into 201 separate (1000x3) matrices. My problem is when I try to do particular combinatio