For huge cases this might be a whiff faster

> with(a, Samples[rowSums(a[, -1], na.rm = TRUE) > 0])
[1] S2 S4
Levels: S1 S2 S3 S4 S5



-----Original Message-----
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of bill.venab...@csiro.au
Sent: Wednesday, 11 August 2010 12:21 PM
To: egg...@gmx.net; r-help@r-project.org
Subject: [ExternalEmail] Re: [R] TRUE FALSE issue

> with(a, Samples[apply(a[,-1], 1, any)])
[1] S2 S4
Levels: S1 S2 S3 S4 S5 

-----Original Message-----
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Alexander Eggel
Sent: Wednesday, 11 August 2010 12:05 PM
To: r-help@r-project.org
Subject: [R] TRUE FALSE issue

How can I extract the samples (S1-S5) containing a TRUE value in their row?
Solution should apply to a much bigger data frame.

> a
Samples A B C D . . .
1 S1 FALSE FALSE FALSE FALSE
2 S2 FALSE FALSE NA TRUE
3 S3 FALSE FALSE FALSE FALSE
4 S4 FALSE TRUE FALSE FALSE
5 S5 FALSE FALSE FALSE FALSE
.
.
.

Thank you guys, I appreciate your help a lot!

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

______________________________________________
R-help@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.

______________________________________________
R-help@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.

Reply via email to