[R] understanding round() behavior

2007-04-24 Thread Robert Duval
Dear all,

I am a little bit puzzled by the way round() works.
Consider the following code

a-123456.3678
 round(a,digits=10)
[1] 123456.4


I would expect the outcome to be something like 123456.3678 or
123456.368, instead the computer gives me 123456.4 no matter how large
the digits are.

Can anybody help me understand what I'm missing here?

Thanks again for your help.
Robert

__
R-help@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.


Re: [R] understanding round() behavior

2007-04-24 Thread jim holtman
'print' by default only prints 7 digits.  See below:

 round(a, digits=10)
[1] 123456.4
 print(round(a, digits=10), digits=10)
[1] 123456.3678



On 4/24/07, Robert Duval [EMAIL PROTECTED] wrote:
 Dear all,

 I am a little bit puzzled by the way round() works.
 Consider the following code

 a-123456.3678
  round(a,digits=10)
 [1] 123456.4


 I would expect the outcome to be something like 123456.3678 or
 123456.368, instead the computer gives me 123456.4 no matter how large
 the digits are.

 Can anybody help me understand what I'm missing here?

 Thanks again for your help.
 Robert

 __
 R-help@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.



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@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.