[R] inconsistent output using 'round'

Bert Gunter gunter.berton at gene.com
Thu Apr 19 23:37:32 CEST 2007


It has nothing to do with round() -- it's the "digits" argument of the print
method that controls the number of digits in the output, print.default in
this case. And the documentation from print.default says for the digits
argument:

"digits: a non-null value for digits specifies the minimum number of
significant digits to be printed in values. The default, NULL, uses
getOption(digits)...." 

And, lo and behold, your output shows a minimum of 3 **significant**  digits
with more being used in tables to line up values that are both greater and
less than 1.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 

 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Bob Green
> Sent: Thursday, April 19, 2007 2:05 PM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] inconsistent output using 'round'
> 
> Peter,
> 
> Many thanks. I have never seen a  confidence interval from 0.000 to 
> 626594160468154480000000000.000 - this is a worry.
> 
> I am also still puzzled why use of digits = 3, produced output which 
> includes 2, 3 and 4 decimal points as per below. The two decimal 
> point values for the coef should have been 2.479, 1.027, 1.614.
> 
> regards
> 
> Bob
> 
>  > print(exp(coef(mod.multacute)),digits = 3)
>           (Intercept) in.acute.dangery violent.convictionsy
> GBH.UW         0.233             3.90                0.714
> homicide       0.183             2.48                0.682
>           in.acute.dangery:violent.convictionsy
> GBH.UW                                    1.03
> homicide                                     1.61
>  > print(exp(confint(mod.multacute)),digits =3)
> , , GBH.UW
> 
>                                        		2.5 % 97.5 %
> (Intercept)                           		0.130  0.417
> in.acute.dangery                     		1.384 10.970
> violent.convictionsy                  	0.213  2.390
> in.acute.dangery:violent.convictionsy 	0.146  7.200
> 
> , , homicide
> 
>                                         		2.5 % 97.5 %
> (Intercept)                           		0.0964  0.349
> in.acute.dangery                     		0.7194  8.543
> violent.convictionsy                  	0.1747  2.660
> in.acute.dangery:violent.convictionsy     0.1767 14.738
> 
> ______________________________________________
> 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.
>



More information about the R-help mailing list