On Fri, 9 Nov 2007, Robin Hankin wrote:

> Hi
>
> [R-2.6.0, macOSX 10.4.10].
>
> The helppage says that rowSums() and colSums()
> are equivalent to 'apply' with  'FUN = sum'.
>
> But I came across this:
>
> > a <- matrix(1:30,5,6)
> > is.integer(apply(a,1,sum))
> [1] TRUE
> > is.integer(rowSums(a))
> [1] FALSE
> >

'equivalent' does not mean 'identical': the wording was deliberate.

> so rowSums() returns a float.

And that is what the help page says it does (albeit more accurately: there 
is no 'float' type, but there is numeric aka double and the result could 
be complex).

> Why is this?

You seem to be asking why R works as documented!

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to