danielkrizian / danielkrizian/rba

fast window apply

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.