danielkrizian / danielkrizian/rba
fast window apply
Open
- Dominant language
- R
- Stars
- 3
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
``` R
wapply <- function(x, width, by = NULL, FUN = NULL, ...)
{
FUN <- match.fun(FUN)
if (is.null(by)) by <- width
lenX <- length(x)
SEQ1 <- seq(1, lenX - width + 1, by = by)
SEQ2 <- lapply(SEQ1, function(x) x:(x + width - 1))
OUT <- lapply(SEQ2, function(a) FUN(x[a], ...))
OUT <- base:::simplify2array(OUT, higher = TRUE)
return(OUT)
}
```
compare with `rollapply`
http://timelyportfolio.blogspot.co.uk/2014/07/speed-tests-for-rollingrunning-functions.html
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.