-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding na.locf #8
Comments
Any particular reason why we want to re-implement this in |
I don't have a specific answer to that question, but I can describe my reasoning behind this issue. First of all, I felt that it would fit nicely with the overall idea of RcppRoll, i.e. filling values in a vector or matrix based on various rules. Second, often one does not need the full time series functionality of zoo or xts, and just uses the roll or na.locf functions. (This is the case for me, since I do most of my stuff with data.table nowadays.) So instead of loading yet another library, I think it would be nice to make RcppRoll more self-contained. Third, na.locf just kills the whole carry forward (or backward) if the maxgap argument is set and the gap is longer than maxgap. This is what I have meant in my previous comment above. While it may make sense for some applications, it may not be what you need in others. Fourth, na.locf in zoo is written in R, which means there are probably some performance gains to be made using Rcpp. I haven't run any benchmarks, but my feeling is that it's not overly fast (while on the other hand I also don't recall it being excessively slow, but looking at the source code, it uses |
I think it would be nice to have the equivalent of
zoo::na.locf
in RcppRoll as well.And it would be nice to limit how far the NAs are carried forward (or backward if
fromLast=T
). This is similar to themaxgap
argument, but the difference is thatmaxgap
just kills everything (which I think is not good, or deserves an additional argument):The text was updated successfully, but these errors were encountered: