[R] extracting one element from all list elements

2009-09-16 Thread Rainer M Krug
Hi I have a list which cosists out of dataframes of the same structure. Now I want to extract one column (let's say column A) from all dataframes and have them in a matrix (or dataframe). At the moment I am doiong: d - data.frame(A=runif(100), B=rnorm(100)) theList - list(e1=d, e2=d, e3=d,

Re: [R] extracting one element from all list elements

2009-09-16 Thread Henrique Dallazuanna
Try this: sapply(theList, '[[', 'A') On Wed, Sep 16, 2009 at 8:34 AM, Rainer M Krug r.m.k...@gmail.com wrote: Hi I have a list which cosists out of dataframes of the same structure. Now I want to extract one column (let's say column A) from all dataframes and have them in a matrix (or

Re: [R] extracting one element from all list elements

2009-09-16 Thread Rainer M Krug
On Wed, Sep 16, 2009 at 1:35 PM, Henrique Dallazuanna www...@gmail.comwrote: Try this: sapply(theList, '[[', 'A') Thanks Henrique - that is much more elegant. Rainer On Wed, Sep 16, 2009 at 8:34 AM, Rainer M Krug r.m.k...@gmail.com wrote: Hi I have a list which cosists out of