[R] Lists of tables and conditional statements
Herbert, Alan G
aherbert at bu.edu
Thu Mar 31 15:11:18 CEST 2011
Thanks Henrique - that worked like a charm - I had tried lots of other combinations before seeing your reply - wished I had asked sooner!
Alan
-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net]
Sent: Wednesday, March 30, 2011 10:09 PM
To: Herbert, Alan G
Cc: r-help at r-project.org Help
Subject: Re: [R] Lists of tables and conditional statements
On Mar 30, 2011, at 7:27 PM, Henrique Dallazuanna wrote:
> Try this:
>
> lapply(l, function(x)x[x[,'Sum'] == 3,])
If this is the right answer, you should send a "solved" message. The dput extract was incomplete.
--
David.
>
> On Wed, Mar 30, 2011 at 7:38 PM, Herbert, Alan G <aherbert at bu.edu>
> wrote:
>> Hi R-users,
>>
>> I have a list containing numeric tables of differing row length. I
>> want to make a new list that contains only rows from tables with a
>> "Sum" greater than 3, plus the names of each table. I was wondering
>> whether there is an elegant way to do this using apply of related
>> functions as this list has many thousands of such tables.
>>
>> Here is an example of the list
>>
>>
>> $AACS
>>
>> POOL
>>
>> INFO pool1 pool2 pool6 pool7 pool8 pool.all Sum
>>
>> 12:125561133:novel 0 0 0 0 1 0 1
>>
>> 12:125570904:novel 0 0 0 0 1 0 1
>>
>> 12:125571014:novel 0 1 0 0 0 0 1
>>
>> 12:125571038:novel 0 0 0 1 0 0 1
>>
>> 12:125575996:novel 0 0 0 1 0 0 1
>>
>> 12:125591844:rs2297478 1 0 1 0 0 1 3
>>
>> 12:125599114:novel 0 0 0 1 0 0 1
>>
>> 12:125612668:novel 0 0 0 0 1 0 1
>>
>> 12:125612839:rs900411 1 0 1 0 1 1 4
>>
>> 12:125626650:novel 0 0 0 0 1 0 1
>>
>> 12:125626737:novel 0 0 0 1 0 0 1
>>
>>
>>
>> $AADAC
>>
>> POOL
>>
>> INFO pool1 pool2 pool5 pool6 pool7 pool8
>> pool.all Sum
>>
>> 3:151542411:novel 0 0 0 0 1 0
>> 1 2
>>
>> 3:151542412:novel 0 0 0 0 1 0
>> 1 2
>>
>> 3:151542643:novel 0 1 0 0 0 0
>> 0 1
>>
>> 3:151545322:rs2410836 0 1 0 0 0 0
>> 1 2
>>
>> 3:151545323:rs62272918 0 1 0 0 0 0
>> 1 2
>>
>> 3:151545509:novel 0 0 1 0 0 0
>> 1 2
>>
>> 3:151545601:rs1803155 1 1 1 1 1 1
>> 1 7
>>
>> 3:151545721:novel 0 0 1 0 0 0
>> 0 1
>>
>> 3:151545802:novel 0 0 0 0 1 0
>> 0 1
>>
>> 3:151545824:novel 0 1 0 0 0 0
>> 0 1
>>
>>
>> Thanks for your help
>>
>> [[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.
>>
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>
> ______________________________________________
> 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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list