search for: direction_func

Displaying 1 result from an estimated 1 matches for "direction_func".

2010 Feb 05
2
ifelse on a series of rows for multiple criteria
...urned for this row (=4). *If* the mean was -571, then a count of the negative values would be returned (=2). If the 7th row was composed of values 1.5, -1.5, 2.5, -2.5, 0? and 0 (i.e. the mean = 0), then -99999 should be returned for this row. I've attempted to construct this code as follows: direction_func <- function(combdframe) { ??? ifelse(mean(i> 0), sum(i> 0), ifelse(mean(i < 0), sum(i < 0), -99999)) ??? } ??? for (i in nrow(combdframe)) { direction <- apply(combdframe[i,],1, direction_func) } ...but this, and varients on this, result in a bit of a mess! Any guidance on...