[R] difference between max in summary table and max function
Franckx Laurent
laurent.franckx at vito.be
Mon Feb 16 13:45:47 CET 2015
Thanks for the clarification. The basic error on my side was that I had misunderstood the "digits" option in the summary, I had not understood that even integer numbers might end up being "rounded". Problem is solved now.
-----Original Message-----
From: Allen Bingham [mailto:aebingham2 at gmail.com]
Sent: zaterdag 14 februari 2015 8:16
To: 'Martyn Byng'; r-help at r-project.org
Cc: Franckx Laurent
Subject: RE: [R] difference between max in summary table and max function
I thought I'd chime in ... submitting the following:
?summary
Provides the following documentation for the default for generalized argument (other than class="data.frame", "factor", or "matrix"):
## Default S3 method:
summary(object, ..., digits = max(3, getOption("digits")-3))
so passing along the object "testrow" w/o a corresponding argument for digits ... defaults to digits=4 (assuming your system has the same default option of digits = 7 that mine does).
... and since later in the documentation it indicates that digits is an:
integer, used for number formatting with signif()
so noting that all of the values you reported from summary(testrow) all have
4 significant digits (including the Max. of 131500) (excepting the min value of "1"), summary() is doing what it is documented to do.
... sorry for being pedantic --- but doing so to point out how helpful the "?" command can be sometimes.
Hope this helps.
______________________________________
Allen Bingham
Bingham Statistical Consulting
aebingham2 at gmail.com
LinkedIn Profile: www.linkedin.com/pub/allen-bingham/3b/556/325
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Martyn Byng
Sent: Friday, February 13, 2015 3:15 AM
To: Franckx Laurent; r-help at r-project.org
Subject: Re: [R] difference between max in summary table and max function
Its a formatting thing, try
summary(testrow,digits=20)
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Franckx Laurent
Sent: 13 February 2015 11:00
To: r-help at r-project.org
Subject: [R] difference between max in summary table and max function
Dear all
I have found out that the max in the summary of an integer vector is not always equal to the actual maximum of that vector. For example:
> testrow <- c(1:131509)
> summary(testrow)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1 32880 65760 65760 98630 131500
> max(testrow)
[1] 131509
This has occurred both in a Windows and in a Linux environment.
Does this mean that the max value in the summary is only an approximation?
Best regards
Laurent Franckx, PhD
Senior researcher sustainable mobility
VITO NV | Boeretang 200 | 2400 Mol
Tel. ++ 32 14 33 58 22| mob. +32 479 25 59 07 | Skype: laurent.franckx | laurent.franckx at vito.be | Twitter @LaurentFranckx
VITO Disclaimer: http://www.vito.be/e-maildisclaimer
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
________________________________________________________________________
This e-mail has been scanned for all viruses by Star.\ _...{{dropped:11}}
More information about the R-help
mailing list