Is there anything like cumsum and cumprod but which allows you to
apply an arbitrary function instead of sum and product? In other words,
I want a function cumfunc(x, f) that returns a vector, so that for all n
up to the length of x
cumapply(x,f)[n] = f(x[1:n])
This would give cumsum
?Reduce
maybe
HTH,
baptiste
2009/9/16 OKB (not okblacke) brenb...@brenbarn.net
Is there anything like cumsum and cumprod but which allows you to
apply an arbitrary function instead of sum and product? In other words,
I want a function cumfunc(x, f) that returns a vector, so that
baptiste auguie wrote:
?Reduce
maybe
No, Reduce reduces an entire vector to a single value by repeatedly
combining adjacent elements. I'm looking to convert a vector to another
vector where each element is some arbitrary aggregating function applied
to the first n elements of the
On Sep 16, 2009, at 5:00 PM, OKB (not okblacke) wrote:
Is there anything like cumsum and cumprod but which allows you to
apply an arbitrary function instead of sum and product? In other
words,
I want a function cumfunc(x, f) that returns a vector, so that for
all n
up to the
On Sep 16, 2009, at 5:09 PM, OKB (not okblacke) wrote:
baptiste auguie wrote:
?Reduce
maybe
No, Reduce reduces an entire vector to a single value by
repeatedly
combining adjacent elements. I'm looking to convert a vector to
another
vector where each element is some arbitrary
On 16-Sep-09 21:17:10, David Winsemius wrote:
On Sep 16, 2009, at 5:09 PM, OKB (not okblacke) wrote:
baptiste auguie wrote:
?Reduce
maybe
No, Reduce reduces an entire vector to a single value by
repeatedly
combining adjacent elements. I'm looking to convert a vector to
another
David Winsemius wrote:
No, Reduce reduces an entire vector to a single value by
repeatedly
combining adjacent elements. I'm looking to convert a vector to
another vector where each element is some arbitrary aggregating
function applied to the first n elements of the
On Sep 16, 2009, at 9:04 PM, OKB (not okblacke) wrote:
David Winsemius wrote:
No, Reduce reduces an entire vector to a single value by
repeatedly
combining adjacent elements. I'm looking to convert a vector to
another vector where each element is some arbitrary aggregating
function
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)
On Sep 16, 2009, at 9:31 PM, OKB (not okblacke) wrote:
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
10 matches
Mail list logo