Re: [R] subsetting a list of dataframes

From: Lara Poplarski <larapoplarski_at_gmail.com>
Date: Tue, 17 May 2011 17:13:35 -0600

Thank you all, this is exactly what I had in mind, except that I still have to get my head around apply et al. Back to the books for me then!

Lara

On Tue, May 17, 2011 at 2:41 PM, Jannis <bt_jannis_at_yahoo.de> wrote:

> Have a look at lapply(). Something like:
>
> entries.with.nrows=lapply(data,function(x)dim(x)[1]>1)
>
> should give you a vector with the elements of the list that you seek marked
> with TRUE.
>
> This vector can then be used to extract a subset from your list by:
>
> data.reduced=data[entries.with.nrows]
>
> Or similar....
>
>
> HTH
> Jannis
>
> --- Lara Poplarski <larapoplarski_at_gmail.com> schrieb am Di, 17.5.2011:
>
> > Von: Lara Poplarski <larapoplarski_at_gmail.com>
> > Betreff: [R] subsetting a list of dataframes
> > An: r-help_at_r-project.org
> > Datum: Dienstag, 17. Mai, 2011 20:24 Uhr
> > Hello All,
> >
> > I have a list of dataframes, and I need to subset it by
> > keeping only those
> > dataframes in the list that meet a certain criterion.
> > Specifically, I need
> > to generate a second list which only includes those
> > dataframes whose number
> > of rows is > 1.
> >
> > Could someone suggest how to do this? I have come close to
> > what I need with
> > loops and such, but there must be a less clumsy way...
> >
> > Many thanks,
> > Lara
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > 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.
> >
>

        [[alternative HTML version deleted]]



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 Tue 17 May 2011 - 23:15:35 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Wed 18 May 2011 - 14:50:07 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