Skip to content

R - Vectorization and Functional Programming Constructs

2 messages · Mingo, Gabor Grothendieck

#
On Fri, Jan 21, 2011 at 10:10 PM, Mingo <catojones at gmail.com> wrote:
If x is supposed to represent a time series that you are trying to
align you would likely be better off to represent it as an object of
one of the time series classes (ts, zoo, xts, timeSeries) and then use
lag.  That way you will not only have a convenient lag function but
all the other functionality that you might need to conveniently handle
such objects.  lag is written in C in both zoo and xts and might be in
timeSeries as well.  If your series is regularly spaced and so
applicable to ts then, internally, lagging only involves manipulating
its "tsp" attribute so it would be extremely fast.