Skip to content
Prev 1642 / 15274 Next

rollapply and cummin

Ah, I had never created a function that way in any of the *apply
functions, I learned something new.  Thank you so much.  R and the R
community is just phenomenal...thank you.


Kent Voss
Koch Quantitative Trading
20 East Greenway Plaza, Suite 450
Houston, TX  77046
Phone: 713.544.5140
Fax: 713.544.6506
kent.voss at kochind.com


 

-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] 
Sent: Thursday, August 23, 2007 7:56 AM
To: Voss, Kent
Cc: r-sig-finance at stat.math.ethz.ch
Subject: Re: [R-SIG-Finance] rollapply and cummin

In that case you might prefer:

# test data
set.seed(1)
z <- zoo(rnorm(25))

rollapply(z, 5, function(x) min(cumsum(x)), align = "left")

which (1) works with the old rollapply too since the function returns a
single number and (2) has the advantage of returning a zoo object rather
than a numeric vector so the time information is not lost.
On 8/23/07, Voss, Kent <VOSSK at kochind.com> wrote:
some period.
repository.
named addressee(s). It must not be disclosed to any person without
proper authority. If you are not the intended recipient, or a person
responsible for delivering it to the intended recipient, you are not
authorized to and must not disclose, copy, distribute, or retain this
message or any part of it.
"EMF <kochind.com>" made the following annotations.
------------------------------------------------------------------------------
The information in this e-mail and any attachments is confidential and intended solely for the attention and use of the named addressee(s). It must not be disclosed to any person without proper authority. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are not authorized to and must not disclose, copy, distribute, or retain this message or any part of it.