Skip to content
Prev 181930 / 398513 Next

arithmetic problem

Since DF is sorted appropriately we could speed that up by avoiding
the repeated function calls done by ave() by or-ing in to your
between() clauses the clause
    ind[-1]==ind[-length(ind)]
as in
    sel1 <- with(DF, c( {dv<-values[-1]-values[-length(values)];dv>200&dv<300} & ind[-1]==ind[-length(ind)], FALSE))
(This one just gives the lower of each pair.)

Someone recently proposed making a function like diff in which you
could insert the operator of your choice, like "==" here, instead of
the usual "-".  That might make code like this easier to understand.