[R] Selecting/Accessing the last vector in a list of a list of data.frames

2009-08-11 Thread Bryan Hanson
Hello Again R Folks: I¹m trying to clean up some code. Suppose I have an object like this: str(test) List of 2 $ G:List of 2 ..$ cls:'data.frame':101 obs. of 2 variables: .. ..$ V1: num [1:101] -0.0019 -0.0019 -0.00189 -0.00188 -0.00186 ... .. ..$ V2: num [1:101] 0.000206 0.000247

Re: [R] Selecting/Accessing the last vector in a list of a list of data.frames

2009-08-11 Thread Henrique Dallazuanna
If I understand correctly your question, you can try something about like this: # Access all elements named 'V1' in your list lapply(test, lapply, '[', 'V1') On Tue, Aug 11, 2009 at 3:49 PM, Bryan Hanson han...@depauw.edu wrote: Hello Again R Folks: I¹m trying to clean up some code.

Re: [R] Selecting/Accessing the last vector in a list of a list of data.frames

2009-08-11 Thread Bryan Hanson
Thanks Henrique. I would have not thought of the syntax you suggest, though it embodies the sort of multilevel (not quite recursive) application of lapply I was thinking of. However, it returns ³test² with V2 missing, everything else intact. Strange; I can't really state in words what I think

Re: [R] Selecting/Accessing the last vector in a list of a list of data.frames

2009-08-11 Thread Benilton Carvalho
what are exactly some operations? if you could provide a reproducible code, it would make it easier to understand what you're trying to achieve. for example, if you were to get the means, you could do something like: theMeans - rapply(test, mean) cheers, b On Aug 11, 2009, at 8:59 PM,