[R] Help me create a hyper-structure

Alaios alaios at yahoo.com
Sat Apr 16 12:32:45 CEST 2011


Dear all 
I would like to have in R a big struct containing a smaller struct. 

I have tried something that I would like to share and ask your help make it work


1) I would like to have a small struct with the following three fields
xorder (an integer ranging from 0 to 20)
yorder (an integer ranging from 0 to 20)
estimated (a 256*256 matrix)

2) I would like to have 10 elements of the struct above
for that I wrote the following:



1) Estimationstruct <- function ( xorder, yorder, estimated) list (xorder= xorder, yoder=yorder,estimated=estimated) 

2) per.sr.struct <-replicate(10,Estimationstruct(vector(mode="integer",length=1),vector(mode="integer",length=1), matrix(data=NA,nrow=256,ncol=256)),simplify=FALSE)


That one worked.
per.sr.struct contains 10 elements and each one of that contains 1).
This works fine:

str(per.sr.struct[[1]])
List of 3
 $ xorder       : int 0
 $ yoder        : int 0
 $ estimated: logi [1:256, 1:256] NA NA NA NA NA NA ..


Then I would like
3) to have 20 times the number two. 
For that I tried out
all.sr.struct<-replicate(20,per.sr.struct)
The idea is to have 20 all.sr.stuct and each element to contain one per.sr.struct.

What is wrong with my reasoning?

Best Regards
Alex

but I am not sure if this works correctly.
I have tried somet



More information about the R-help mailing list