On Tue, 2008-07-15 at 14:35 -0700, Rheannon wrote: > 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. > Hi Rheannon,
How about: sum(DF[DF<0]) Jim ______________________________________________ R-help@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.