[R] Help me create a hyper-structure

From: Alaios <alaios_at_yahoo.com>
Date: Sat, 16 Apr 2011 03:32:45 -0700 (PDT)


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:
  3. Estimationstruct <- function ( xorder, yorder, estimated) list (xorder= xorder, yoder=yorder,estimated=estimated)
  4. 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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 16 Apr 2011 - 10:35:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 16 Apr 2011 - 15:00:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive