[R] Row Sum, exclude positive values

From: Rheannon <rbrooks_at_uvic.ca>
Date: Tue, 15 Jul 2008 14:35:31 -0700 (PDT)

Hello,

I'd like to sum the values of a row from the first negative number (FN) to the last negative number (LN), but not add any positive values to the sum. Then apply this to each row of the data frame.

For example if I have a dataframe with Row 1 values DF = (4, 3, 2, 1, 0, -1, -2, -3, -2, 2, 1, -1, -2, -3, -2, -1, 1, 2) I would like to sum the numbers from column 6 to column 16, but not include column 10 & 11.

I believe it would look something like

function(x)while x[FN + 1] != 0 && x[FN] != LN sum(x[FN] to x[FN + 1]); FN = FN + 1

But I cant seem to get the sintax right. Could someone help me?
Cheers,
R

-- 
View this message in context: http://www.nabble.com/Row-Sum%2C-exclude-positive-values-tp18475407p18475407.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 15 Jul 2008 - 23:46:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Jul 2008 - 00:32:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive