From simon.urbanek at r-project.org  Mon Jan  9 22:04:06 2006
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Mon, 9 Jan 2006 16:04:06 -0500
Subject: [Rd] prod(numeric(0)) surprise
In-Reply-To: <556e90a80601091235r19bab40au330337b22ec6da42@mail.gmail.com>
References: <43C1C973.8080702@zoo.ufl.edu> <43C1CBB9.7090307@stats.uwo.ca>
	<43C1CD05.2030504@zoo.ufl.edu>
	<17346.5951.435355.767827@stat.math.ethz.ch>
	<6phslrxz4dg.fsf@gopher3.fhcrc.org> <43C2A149.5030903@stats.uwo.ca>
	<556e90a80601091235r19bab40au330337b22ec6da42@mail.gmail.com>
Message-ID: <79E1B788-0E53-4D00-AD50-F12E18DCA37D@r-project.org>

On Jan 9, 2006, at 3:35 PM, Kjetil Halvorsen wrote:

> But this thread seems to have pointed to some inconsistencies:
>
>> cumprod( numeric(0) )
> numeric(0)
>> cumsum( numeric(0) )
> numeric(0)
>
> shouldn't this give the same as prod() and sum() in this case?

No - as Thomas explained very nicely they are a different kind of  
functions. cumXXX are n-to-n length vector functions, whereas prod/ 
sum are n to 1 vector length functions. So R is in fact very  
consistent and Thomas did exactly describe the rules.

Cheers,
Simon



[Rd] prod(numeric(0)) surprise
Simon Urbanek