Re: [R] ifelse on a series of rows for multiple criteria

2010-02-05 Thread David Winsemius
On Feb 5, 2010, at 10:48 AM, Steve Murray wrote: Dear all, I am attempting to perform a calculation which counts the number of positive (or negative) values based on the sample mean (on a per-row basis). If the mean is>0 then only positive values should be counted, and if the mean is <0

Re: [R] ifelse on a series of rows for multiple criteria

2010-02-05 Thread Thomas Liebig
Hi Steve, as far as i understood, you're trying to do this: direction_func <- function(combdframe) { ifelse(mean(combdframe==0), -9, sum((sign(mean(combdframe))*combdframe)>0)) } direction<-apply(combdframe, 1, direction_func) direction cheers, thomas -- Thomas Liebig Fraunhofe

[R] ifelse on a series of rows for multiple criteria

2010-02-05 Thread Steve Murray
Dear all, I am attempting to perform a calculation which counts the number of positive (or negative) values based on the sample mean (on a per-row basis). If the mean is>0 then only positive values should be counted, and if the mean is <0 then only negative values should be counted. In cases w