[R] Anything like associative arrays in R?
kynn@panix.com
kynn at panix.com
Wed Nov 2 14:24:14 CET 2005
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
More information about the R-help
mailing list