[R] summary() vs mean()
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Feb 1 18:56:21 CET 2001
> Date: Thu, 01 Feb 2001 09:47:02 -0800
> To: Prof Brian D Ripley <ripley at stats.ox.ac.uk>
> From: "Marc R. Feldesman" <feldesmanm at pdx.edu>
> Subject: Re: [R] summary() vs mean()
> Cc: <r-help at stat.math.ethz.ch>
>
> Below is output after fixing summary.data.frame as you suggest. This
> output now matches that in SPlus 2000 and SPlus 6.0 (Win Beta 2).
>
> However, in light of the issue of significant digits, there still seems to
> be an inconsistency here (both in R and S dialects). All the values for
> body weight print (?have) one decimal digit, while all the values for brain
> weight print (?have) 4. Since all the original values in the data file are
> recorded without decimal digits at all, I find it strange that the (for
> example) minimum for body weight is 3.0, while the minimum for brain weight
> is 26.0000. They're 3 and 26, respectively, in the original data
> file. Why should one be reported to one decimal digit and the other to
> 4? This pattern follows throughout.
[The fix I committed is different (passing digits=12, in fact).]
The issue is that the whole column is printed to 8 sf (which you asked
for but got 7 in S+6.0) and all the numbers are aligned on the decimal
point. The column is formatted, not each number, which is what one
usually wants. As the mean really is (I presume since there are 15
animals) 761.2, only one dp is needed to give 8 sf.
> I don't think this is an R problem since a similar pattern (but with 3
> decimal digits) occurs in S-Plus.
>
>
> S-Plus 6.0 (Win, Beta) OUTPUT
> > summary(mammals, digits=8)
> Body.Weight Brain.Weight
> Min.: 3.0 Min.: 26.000
> 1st Qu.: 35.5 1st Qu.: 138.500
> Median: 100.0 Median: 406.000
> Mean: 761.2 Mean:1000.467
> 3rd Qu.: 493.0 3rd Qu.: 667.500
> Max.:6654.0 Max.:5712.000
> >
>
> Obviously this isn't a giant problem, but one that a student first brought
> to my attention and I've been scratching my head trying to puzzle it out
> ever since.
>
> R-1.2.1 (Windows, Binary after Brian Ripley's code fix)
>
> > summary(mammals, digits=8)
> Name Body.Weight Brain.Weight
> Red Fox :1 Min. : 3.0 Min. : 26.0000
> Pig :1 1st Qu.: 35.5 1st Qu.: 138.5000
> Man :1 Median : 100.0 Median : 406.0000
> Kangaroo:1 Mean : 761.2 Mean :1000.4667
> Jaguar :1 3rd Qu.: 493.0 3rd Qu.: 667.5000
> Horse :1 Max. :6654.0 Max. :5712.0000
> (Other) :9
[...]
--
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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list