Is this what you want?
 x <- list()
for (i in c('test', 'some', 'more')){
for(j in c('lv1', 'lv2', 'lv3')){
x[[i]][[j]] <- runif(10)
}
}
x
x[['some']][['lv2']]


 On 11/2/05, kynn@panix.com <kynn@panix.com> wrote:
>
>
>
>
>
> Let me preface my question by stressing that I am much less interested
> in the answer than in learning a way I could have *found the answer
> myself*. (As helpful as the participants in this list are, I have far
> too many R-related questions to resolve by posting here, and as I've
> written before, in my experience the R documentation has not been very
> helpful, but I remain hopeful that I may have managed to miss some
> crucial document.)
>
> The task I want to accomplish is very simple: to define and
> sequentially initialize M x N variables *programmatically*, according
> to two different categories, containing N and M values, respectively.
>
> In languages with associative arrays, the typical way to do this is to
> define a 2-d associative array; e.g. in Perl one could do
>
> for $i ( 'foo', 'bar', 'baz' ) {
>
> for $j ( 'eenie', 'meenie', 'minie', 'moe' ) {
>
> $table{ $i }{ $j } = read_table( "path/to/data/${i}_${j}.dat" );
> }
>
> }
>
> How does one do this in R? In particular, what's the equivalent of
> the above in R?
>
> Most importantly, how could I have found out this answer from the
> R docs?
>
> Many thanks in advance,
>
> kj
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

	[[alternative HTML version deleted]]


