[R] R-2.2.0: aggregate problem

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Nov 7 22:41:14 CET 2005


On Mon, 7 Nov 2005 jfontain at free.fr wrote:

>> aggregate(as.ts(c(1,2,3,4,5,6,7,8,9,10)),1/2,mean)
> Time Series:
> Start = 1
> End = 9
> Frequency = 0.5
> [1] 1.5 3.5 5.5 7.5 9.5
>> aggregate(as.ts(c(1,2,3,4,5,6,7,8,9,10)),1/5,mean)
> Error in sprintf(gettext(fmt, domain = domain), ...) :
> 	use format %f, %e or %g for numeric objects
>>
>
> I must be doing something wrong, but what?

It is rounding error: 1 is just under a multiple of 1/5 (in computer 
representation).  Try

aggregate(as.ts(c(1,2,3,4,5,6,7,8,9,10)),1/5.000000000000001,mean)

Clearly it needs an internal fix (and for the reporting error), and 
R-patched now has one.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list