Jason: Please read AND FOLLOW the posting guide on how to ask clear questions. Here, you need to more carefully define what you mean by "the last 3 days." Do you mean:(a) the last 3 values in the series (including or excluding the present one?) or the last 3 calendar days -- e.g. for 10-05, only 10-05 and 10-04, since 10-01 is not within the last 3 calendar days.Also, do you have missing values, and, if so, how do you want to handle them.
If you mean the former, for small amounts of data without any missings(say 100 million numeric values or less) and small n (like n=3), it's easy and should be pretty fast just to produce lagged columns and use pmax rowwise. If you mean the latter and have missing values, it may be considerably more difficult. However, offering anything more seems pointless until you have adequately specified what you want. Reproducible data and code for a start. Cheers, Bert On Thu, Oct 28, 2010 at 9:27 AM, Jason Kwok <jayk...@gmail.com> wrote: > I'm having trouble returning a rolling n period highest value for a data > set. For each day I want to calculate the highest value over the last 3 > days. I am using the following packages: zoo, xts, quantmod and TTR. > > Thanks, Jason > > GLD.Close > 2010-10-01 128.91 > 2010-10-04 128.46 > 2010-10-05 130.99 > 2010-10-06 131.81 > 2010-10-07 130.37 > 2010-10-08 131.66 > 2010-10-11 132.29 > 2010-10-12 131.96 > 2010-10-13 134.07 > 2010-10-14 134.75 > 2010-10-15 133.68 > 2010-10-18 134.28 > 2010-10-19 130.11 > 2010-10-20 131.32 > 2010-10-21 129.47 > 2010-10-22 129.73 > 2010-10-25 130.85 > 2010-10-26 130.88 > 2010-10-27 129.52 >> > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Bert Gunter Genentech Nonclinical Biostatistics ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.