[R] Howto store objects in a matrix or in an array

Lars Feistner lars.feistner at iwr.uni-heidelberg.de
Wed Sep 29 16:09:38 CEST 2004


i am working with the R.oo package. I want to store objects (instances 
of classes) in a n-dimensional array.
I tried this:

t <- array(list(),dim=c(8,8))
t[1,1] <- someObject
print(t[1,1])  results in:
[1] NA

the same with any S4 classes
t1 <- new("track",x=1:5,y=5:10)
t[1,1] <- t1
Error in "[<-"(`*tmp*`, 1, 1, value = t1) :
        nothing to replace with

Is there any chance not to use a list in list construction?

Lars Feistner

Lars Feistner                                   feistner at justis.de

Untere Neckarstr 32                             Tel:  +49 6221 8935279
D-69117 Heidelberg                              Mobil:+49 173 3205195

More information about the R-help mailing list