I've done stuff like this before but
it's been a while and I'm stuck.
 
Suppose I have a matrix with one
column x and another column y
and both are numeric and let the
row index of the matrix be i
 
Starting at index i ( i would equal on the first iteration )
when the cumulative sum of x_i+1 - x_i
is greater than W = some constant, I want to mark that spot in the
row, call it  i^* and sum all the values in y between  i and  i^* and
put that value
a third column z. Otherwise, the values in the indices of z
between i and  i^*-1  should be NA.
 
Then, start at i^*+1 and do the same thing again.
and keep doing thisn until I get all the way through the rows
of the matrix.
 
I think this is tricky but I used to do it and I forgot how to.
If it has to be done using loops, that's okay but
from previous experience, I don't think looping is necessary.
 
Thanks.
 
                                      Mark
  


**********************************************************************
This email and any files transmitted with it are confidentia...{{dropped}}

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to