[Rd] prod(numeric(0)) surprise

Simon Urbanek simon.urbanek at r-project.org
Mon Jan 9 22:04:06 CET 2006


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



More information about the R-devel mailing list