[R] Summary shows wrong maximum
Gavin Simpson
gavin.simpson at ucl.ac.uk
Mon Dec 4 13:06:19 CET 2006
On Mon, 2006-12-04 at 12:04 +0100, Sebastian Spaeth wrote:
> Hi all,
> I have a list with a numerical column "cum_hardreuses". By coincidence I
> discovered this:
>
> > max(libs[,"cum_hardreuses"])
> [1] 1793
>
> > summary(libs[,"cum_hardreuses"])
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> 1 2 4 36 14 1790
>
> (note the max value of 1790) Ouch this is bad! Anything I can do to remedy
> this? Known bug?
Did you read ?summary, which has:
## Default S3 method:
summary(object, ..., digits = max(3, getOption("digits")-3))
so this is a rounding issue of the *printed* representation of the
summary. Just change digits to be a larger number:
> dat <- rnorm(100)
> max(dat)
[1] 2.434443
> summary(dat)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-2.21100 -0.65450 0.03793 0.06919 0.84650 2.43400
> summary(dat, digits = 10)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-2.21106232 -0.65451716 0.03793040 0.06919486 0.84652269 2.43444263
> # same with integer as in your example
> dat <- floor(dat * 1000000)
> max(dat)
[1] 2434442
> summary(dat)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-2211000 -654500 37930 69190 846500 2434000
> summary(dat, digits = 10)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-2211063.00 -654517.50 37930.00 69194.38 846522.00 2434442.00
HTH
G
>
> This is a Version 1.16 (3198) of the MacOSX R.
>
> Regards,
> Sebastian Spaeth
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [t] +44 (0)20 7679 0522
ECRC & ENSIS, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list