Weijie Cai <wcai11 <at> hotmail.com> writes:

: 
: Hi list,
: 
: I want to create a two (possibly three) dimensional array of objects. These 
: objects are classes in object oriented style. I failed by using
: a<-array(NA,c(m,n))
: for (i in 1:m){
:   for (j in 1:n){
:     a[i,j]<-My.Obj
:   }
: }
: 

A list that has a dim attribute should do it:

R> x <- list(12, "abc", 3i, sin)
R> dim(x) <- c(2,2)
R> x
     [,1]  [,2]
[1,] 12    0+3i
[2,] "abc" ?   
R> x[[2,2]](pi/180)
[1] 0.01745241

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to