s-news
[Top] [All Lists]

[S] max of 'x' previous obs in a vector

To: s-news@wubios.wustl.edu
Subject: [S] max of 'x' previous obs in a vector
From: paul_chartraw@westlb.co.uk
Date: Thu, 24 Jun 1999 14:53:00 +0100
Sender: owner-s-news@wubios.wustl.edu

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

<Prev in Thread] Current Thread [Next in Thread>
  • [S] max of 'x' previous obs in a vector, paul_chartraw <=