Hi Joao,
Here is one way (d is your data set):
d[apply(d == 'P', 1, any),]
HTH,
Jorge
On Wed, Aug 31, 2011 at 1:28 PM, Joao Fadista <> wrote:
> Dear all,
>
> I would like to know how to subset a data.frame by rows.
>
> Example:
>
> Probesets34884348883489
If your data frame is called 'df', then
something like the following should work:
df[ apply(as.matrix(df[,-1]), 1, function(x) any(x == "P")), ]
This creates a logical vector as long as the
number of rows. As Bill Dunlap recently noted,
'apply' really wants a matrix and not a data frame.
On 31
Suppose your data is called df.
df[rowSums(df == "P")>0,]
In short, this tests each element for equality for "P", sums the number of
"P"s found and subsets when that number is >0.
Michael
On Wed, Aug 31, 2011 at 1:28 PM, Joao Fadista wrote:
> Dear all,
>
> I would like to know how to subset a
Dear all,
I would like to know how to subset a data.frame by rows.
Example:
Probesets348843488834892
1 19676_at A AA
2 10001_atP P P
3 10002_at
4 matches
Mail list logo