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
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of OKB (not okblacke)
> Sent: Wednesday, September 16, 2009 6:04 PM
> To: r-h...@stat.math.ethz.ch
> Subject: Re: [R] Generalized cumsum?
>
&g
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 okbl
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:
>> 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 t
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
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 aggre
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 lengt
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 t
?Reduce
maybe
HTH,
baptiste
2009/9/16 OKB (not okblacke)
>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
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
11 matches
Mail list logo