Re: [R] taking rows from data.frames in list to form new data.frame?

From: Hadley Wickham <hadley_at_rice.edu>
Date: Thu, 21 Apr 2011 07:02:32 -0500

On Wed, Apr 20, 2011 at 6:36 PM, Dennis Murphy <djmuser_at_gmail.com> wrote:
> Hi:
>
> Perhaps you're looking for subset()? I'm not sure I understand the
> problem completely, but is
>
> do.call(rbind, lapply(database, function(df) subset(df, Symbol == 'IBM')))
>
> or
>
> library(plyr)
> ldply(lapply(database, function(df) subset(df, Symbol == 'IBM'), rbind)

That's a bit redundant. All you need is:

ldply(database, function(df) subset(df, Symbol == 'IBM'))

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 21 Apr 2011 - 12:05:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Apr 2011 - 12:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive