[R] Generalized cumsum?

OKB (not okblacke) brenbarn at brenbarn.net
Thu Sep 17 03:31:17 CEST 2009


David Winsemius wrote:

>   cumapply <- function (FUN, X)
>   { FUN <- match.fun(FUN)
>     answer <- sapply(1:length(X), function(x) { FUN(X[1:x])} )
>       return(answer)}

    	Cool, thanks.  It's still interesting to me that there's no such 
thing built-in.

Best wishes,
-- 
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is
no path, and leave a trail."
	--author unknown




More information about the R-help mailing list