[R] How to identify the rows in my dataframe with a negative value in any column?
David Winsemius
dwinsemius at comcast.net
Tue Nov 24 21:37:37 CET 2009
On Nov 24, 2009, at 3:04 PM, Henrique Dallazuanna wrote:
> Try this:
>
> DF[rowSums(DF < 0) == 0,]
ITYM:
> DF <- data.frame(a=1:10, b=c(1:3,-4, 5:10), c=c(-1, 2:10))
>
> DF[rowSums(DF < 0) > 0,]
a b c
1 1 1 -1
4 4 -4 4
--
David
> On Tue, Nov 24, 2009 at 5:58 PM, Mark Na <mtb954 at gmail.com> wrote:
>> Dear R-helpers,
>>
>> I have a dataframe that should not contain any negative values, but
>> it does.
>> I wish to print the rows from my dataframe that contain a negative
>> value in
>> any column. I've tried this:
>>
>>> dataframe[dataframe<0,]
>>
>> but it just returns a row of NAs.
>>
>> I would very much appreciate any help with this you could provide.
>>
>> Thanks, Mark
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list