[R] Aggregate lag

From: Matthieu Cornec <matthieu.cornec_at_gmail.com>
Date: Tue 10 May 2005 - 20:55:52 EST


hello,

Does anybody know how to aggregate a lag series ? when I try to use aggregate I get the following message

> try<-ts(1:100,start=c(1985,1),freq=12)
> aggregate(try,4,mean,na.rm=T)

    Qtr1 Qtr2 Qtr3 Qtr4
1985 2 5 8 11
1986 14 17 20 23
1987 26 29 32 35
1988 38 41 44 47
1989 50 53 56 59
1990 62 65 68 71
1991 74 77 80 83
1992 86 89 92 95
1993 98
> aggregate(lag(try,-1),4,mean,na.rm=T)
Error in rep.int("", start.pad) : invalid number of copies in rep()

Matthieu



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 10 21:02:50 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:40 EST