Re: [R] Help me create a hyper-structure

From: Alaios <alaios_at_yahoo.com>
Date: Mon, 18 Apr 2011 01:45:44 -0700


It seems you were right.
Now I can easily access my struct and substruct like this

# all.str[[1]]] Gives access to the first struct of per.sr.struct which containts 101 times the xorder,yorder,estimation.sr
# all.str[[1]][[2]] Gives access to the second substruct of all.str[[1]]
# all.str[[1]][[2]][[3]] Gives access to the matrix.

Now I would like to ask you if in R cran I can make struct assignments like this

    all.str[[i]]<-TempApproxstruct

where all.str[[i]] is a list that contains 100 times the  $ :List of 3

  ..$ xorder       : int 0
  ..$ yoder        : int 0
  ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
 $ :List of 3
  ..$ xorder       : int 0
  ..$ yoder        : int 0

  ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ... .... and so on

where str(temp.per.sr.struct) is a list that contains 100 times the  $ :List of 3

  ..$ xorder       : int 0
  ..$ yoder        : int 0
  ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...
 $ :List of 3
  ..$ xorder       : int 0
  ..$ yoder        : int 0

  ..$ estimation.sr: logi [1:256, 1:256] NA NA NA NA NA NA ...   [list output truncated]
...and so on.

Will R understand this kind of assignments or not?

I would like to thank you in advance for your help Best Regards
Alex

> From: Ben Bolker <bbolker@gmail.com>
> Subject: Re: [R] Help me create a hyper-structure
> To: r-help_at_stat.math.ethz.ch
> Date: Saturday, April 16, 2011, 3:39 PM
> Alaios <alaios <at>
> yahoo.com> writes:
>
> >
> > Dear all
> > I would like to have in R a big struct containing a
> smaller struct.
> >
> > 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:
> >
> Estimationstruct <- function ( xorder, yorder,
> estimated) {
>   list (xorder= xorder,
> yorder=yorder,estimated=estimated)
> }
>
> per.sr.struct <- replicate(10,
>          
>    Estimationstruct(0L,0L,matrix(nrow=256,ncol=256)),
>    simplify=FALSE)
>
> > That one worked.
> > per.sr.struct contains 10 elements and each one of
> that contains 1).
>
> all.sr.struct
> <-   replicate(20,per.sr.struct,simplify=FALSE)
>
> > The idea is to have 20 all.sr.stuct and each element
> > to contain one per.sr.struct.
>
>   I think you just missed simplify=FALSE in the last
> step ...
>
> ______________________________________________
> 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.
>



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 Mon 18 Apr 2011 - 08:48:10 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 Mon 18 Apr 2011 - 13:40:31 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