-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGZILLA #16620] Display of summary of numeric vector containing Inf is incorrect #6007
Comments
The reason this happens is that the print method calls zapsmall() on the entries. Compared to Inf, every finite number is small. I agree the behaviour is ugly. Perhaps only the finite values should be zapped? On the other hand, summary.default prints ugly results by design (e.g. summary(123456) rounding the entries), so I'm not sure everyone would agree on changing this. METADATA
|
Created attachment 1941 [details] METADATA
INCLUDED PATCH
|
Thanks for the response, knowing about zapsmall() really helps me understand this. A few comments though Another issue with what I'm bringing up here is that it's not simply a matter of everything being small compared to infinity -- it seems that it simply truncates decimals places but otherwise respects significant digits
Min. 1st Qu. Median Mean 3rd Qu. Max.
Min. 1st Qu. Median Mean 3rd Qu. Max. As to your example about summary(123456), while we might be able to argue about the ideal behavior here, I would not have submitted it as a bug report because at least there is an option to get it to display correct results.
Min. 1st Qu. Median Mean 3rd Qu. Max.
Min. 1st Qu. Median Mean 3rd Qu. Max. As it stands, printing summary with an Inf will provide mostly useless results if run on numeric data with an absolute value less than 1 no matter what options you provide. This is made more confusing by the fact that you get expected results if run on numeric data without decimal places. In an attempt to not be a total leech, I followed through on where you pointed me to and attached a modification to /src/library/base/R/zapsmall.R that would fix this behavior (only added 1 line and modified another). In case it's thought that modification of zapsmall would mess up something else, I'll also make a change to /src/library/base/R/summary.R that only affects this specific issue. METADATA
|
I can't figure out if there is a way to edit my patch or change old comments, but I wanted to say that I'm having trouble testing/compiling R at the moment. I've done it plenty of times before, but having some trouble on the current machine. It seems like it should be good to me, but I'm too new to know better. Sorry about that. METADATA
|
I've made a less extreme patch than yours, only changing the summary print and format methods, not zapsmall itself. Will commit after testing. METADATA
|
The display of a summary of a numeric vector containing Inf does not round correctly.
0.1000000000000000055511 0.2000000000000000111022 0.2999999999999999888978 0.2999999999999999888978 0.4000000000000000222045
Max.
0.5000000000000000000000
Min. 1st Qu. Median Mean 3rd Qu. Max.
0 0 0 Inf 0 Inf
Note that the error is in the display, and not the calculation
[1] 0.1000000000000000055511 0.2000000000000000111022 0.2999999999999999888978 Inf 0.4000000000000000222045
[6] Inf
METADATA
The text was updated successfully, but these errors were encountered: