Perhaps this is obvious...but is there anyway to create a matrix like object with has more than 2 dimensions. I want to estimate a bunch of var/cov matrices inside an index loop. It would be more computationally efficient to do this in C...but R makes many of the operations inside the loop really easy! Thanks. -- Tony Long Ecology and Evolutionary Biology Steinhaus Hall University of California at Irvine Irvine, CA 92697-2525 Tel: (949) 824-2562 (office) Tel: (949) 824-5994 (lab) Fax: (949) 824-2181 email: tdlong at uci.edu http://hjmuller.bio.uci.edu/~labhome/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Q: Perhaps this is obvious...but is there anyway to create a matrix like object with has more than 2 dimensions. I want to estimate a bunch of var/cov matrices inside an index loop. It would be more computationally efficient to do this in C...but R makes many of the operations inside the loop really easy! Thanks. -- A: Look at array(). I'm not sure I understand, but you might be able to use the index for one of the array's dimensions, and the two other dimensions for each matrix. Arrays can have more than 3 dimensions. Jon Baron -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Perhaps this is obvious...but is there anyway to create a matrix like > object with has more than 2 dimensions.Yes. They're called arrays in R. my.array<-array(0,dim=c(10,5,6,8)) will give you a 4-dimensional 10 x 5 x 6 x 8 array. Have a look at the source for "spectrum" in the ts library for a good example of their use.> I want to estimate a bunch > of var/cov matrices inside an index loop. It would be more > computationally efficient to do this in C...but R makes many of the > operations inside the loop really easy!You can, of course, migrate the innermost portions of the loop out to C or Fortran after polishing it in R. And yes, R makes it much easier. Debugging pointers in variable-sized 4-d arrays isn't my idea of a good time. ;-) Cheers Jason -- Indigo Industrial Controls Ltd. 64-21-343-545 jasont at indigoindustrial.co.nz -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._