[R] indexing data.frames

Uwe Ligges ligges at statistik.uni-dortmund.de
Sun Mar 3 21:39:42 CET 2002



graham lawrence wrote:
> 
> Dear R-help,
> 
> I have a series of data.frames (i1,i2,...,in) all containing the same number
> of items, but dissimilar content.  I would like to instal them in another
> data.frame, say index, so that I can access their items with index[i,j].
> 
> No matter how I try to set index up, its subframes cannot be indexed,
> because they all have the row number of 1.  What am I doing wrong? (I get
> the same result with lists, a data.frame of lists, or a list of data.frames)
> 
> Alternatively, does R contain an equivalent to the INDIRECT function found
> in spreadsheets, so that instead of doing, say, edit(i6), I could get
> instead edit(the vector named by the content of i6)?

I'm not quite sure if I understand your question correctly.
Here an example for indexing data.frames in a list:

 x <- data.frame(a1=1:10, b1=2:11)
 y <- data.frame(a2=11:20, b2=12:21)
 L <- list(x=x, y=y)
 
 L # two data.frames in a list.
 L[[1]][[1]][1] # first list element, first col, first item
 L[[1]][[2]][3] # first list element, second col, third item
 L[[2]][[2]][10] # second list element, second col, last item

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list