I would like to apply a function 'f' to the lagged version of a vector and
the vector itself.

This is easy to do explicitly:

      mapply( f, v[-1], v[-length(v)] )

or in the case of a pointwise vector function, simply

      f( v[-1], v[-length(v)] )

This is essentially the same as 'diff' but with an arbitrary function, not
'-'.

Is there a standard way to do this? Is there any particular reason that
'diff' should not have an 'f' argument?

            -s

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to