[R] Counting by rows based on multiple criteria
Steve Murray
smurray444 at hotmail.com
Mon Feb 8 12:54:55 CET 2010
Dear all,
I have a data frame of 6 columns and ~60000 rows which I hope to perform the following calculation on.
For each row, I wish to determine whether there are a greater number of positive or negative numbers. Then, if there are more positive numbers in the row, count how many occur - but if there are more negative numbers in the row, count them instead and insert a minus symbol before (e..g -4, to denote that this was determined on negative numbers).
If the number of positive and negative numbers in a given row are equal, then return a zero for that row.
Finally, if all values in a row are zero (i.e. neither positve or negative) then return -99999.
I've had a go at this myself for some considerable time, trying the use of an 'apply' (by rows) function, but seem unable to successfully achieve the above.
Any help would be very gratefully received.
Many thanks,
Steve
_________________________________________________________________
Do you have a story that started on Hotmail? Tell us now
More information about the R-help
mailing list