Is there a non-recursive method of accomplishing the below?
function(prices, period)
{
period <- period - 1
pricemax <- prices
pricemax[1:length(prices)] <- NA
for(i in period + 1:length(prices))
pricemax[i] <- max(prices[(i - period):i])
pricemax <- pricemax[1:length(prices)]
pricemax
}
_________________________________________________________________________
The information contained in this message is intended for the addressee
only and may contain confidential and/or privileged information.
If you are not the addressee, please delete this message and notify the
sender; you should not copy or distribute this message or disclose its
contents to anyone.
Any views or opinions expressed in this message are those of the author
and do not necessarily represent those of WestLB or any of its affiliates.
No reliance may be placed on this message without written confirmation
from an authorised representative of its contents.
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|