# [Rd] aggregate.ts (PR#514)

**plummer@iarc.fr
**
plummer@iarc.fr

*Tue, 11 Apr 2000 12:27:28 +0200 (MET DST)*

aggregate.ts does not behave in the same way as the equivalent
method aggregate.rts in S-PLUS. In particular it
- changes the start of the time series
- tends to have a length which is 1 shorter
For example:
R> x <- ts(1:10)
R> aggregate(x, nfreq=0.5, FUN=min)
Time Series:
Start = 2
End = 8
Frequency = 0.5
[1] 2 4 6 8
S> x <- rts(1:10)
S> aggregate(x, nf=0.5, fun = min)
[1] 1 3 5 7 9
start deltat frequency
1 2 0.5
I have edited the aggregate.ts function to reproduce the S-PLUS
behaviour, which I find more intuitive:
old:
#nstart <- ceiling(tsp(x)[1] * nfrequency)/nfrequency
#x <- as.matrix(window(x, start = nstart))
new:
nstart <- tsp(x)[1]
# Can't use nstart <- start(x) as this causes problems if
# you get a vector of length 2.
x <- as.matrix(x)
I have tried this on a range of examples and have not encountered
any problems, but of course I may be missing something.
Martyn
--please do not edit the information below--
Version:
platform = i686-unknown-linux
arch = i686
os = linux
system = i686, linux
status =
major = 1
minor = 0.0
year = 2000
month = February
day = 29
language = R
Search Path:
.GlobalEnv, Autoloads, package:base
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._