Hola! I am working on a problem where data points are (square) matrices. Is there a way to make a "vector" of matrices, such that it can be stored in a data.frame? Can that be done with S3? or do I have to learn S4 objects & methods? Kjetil
Bonjour, On Oct 16, 2009, at 11:36 AM, Kjetil Halvorsen wrote:> Hola! > > I am working on a problem where data points are (square) matrices. Is > there a way to make a > "vector" of matrices, such that it can be stored in a data.frame? Can > that be done with S3? > or do I have to learn S4 objects & methods?Not know anything about your problem, I'd suggest to try to think about your problem in terms of storing these matrices in a list. For example, assume you have matrices m1 to m10 my.stuff <- list(m1, m2, ..., m10) If you can elaborate more on your specific case (or perhaps a simpler one that can demonstrate your use case), perhaps we can help you think it through a bit. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact
On Fri, Oct 16, 2009 at 4:36 PM, Kjetil Halvorsen <kjetilbrinchmannhalvorsen at gmail.com> wrote:> Hola! > > I am working on a problem where data points are (square) matrices. Is > there a way to make a > "vector" of matrices, such that it can be stored in a data.frame? Can > that be done with S3? > or do I have to learn S4 objects & methods? >If the matrices are all the same size then you could store them in an array, which is essentially a 3 or more dimensional matrix. Otherwise, you can store them in a list, and get them by number: foo = list(matrix(1:9,3,3),matrix(1:16,4,4)) foo[[1]] foo[[2]] and so forth. You'll only need to create new object classes (with S3 or S4) if you want special behaviour of vectors of these things (such as plot(foo) doing something sensible). With S3 it's easy: class(foo)="squareMatrixVector" plot.squareMatrixVector=function(x,y,...){ cat("ouch\n") } plot(foo) ouch Barry
Apparently Analagous Threads
- mgcv in R-2.4.0.alpha
- CompeticiÃn de classificación!!! Fwd: [R] Classification of supernovae - a challenge
- some questions about sympy (that is, rSymPy)
- problem building R from svn repo
- How to get around heteroscedasticity with non-linear leas t squares in R?