Hello dear R users!

I did not find a function which gives information about the number of 
digits of a value shown by R.
Do you know one?

I need it to solve the problem (see RFAQ 7.31)that 0.2==0.2+0.1-0.1 FALSE
The solution suggested in RFAQ is to use isTRUE(all.equal(0.2,0.2+0.1-0.1))

But if I want to compare inequality:
0.2<=0.2 +0.1-0.1 TRUE
but 0.2<=0.2 +0.1-0.1 FALSE
bad!
but in this case all.equal does not work I think... Unless to write a 
double condition like
0.2>0.2 +0.1-0.1 | isTRUE(all.equal(0.2,0.2 +0.1-0.1))

The solution I found is to round the values, because 
0.2==round(0.2+0.1-0.1,2) TRUE
However, one has to know the number of digits of the target value. How 
can you do when it is unknown?

What I mean is if R shows 2.3456 I want to obtain the info that digits=4 
even if in facts the value has more (internal) digits.

I did not find a way to represent the number of digits but I found that 
as.numeric(as.character(x)) rounds the values to the number of digits 
shown. But is there a better way to make it?

Thanks!

______________________________________________
R-help@r-project.org 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.

Reply via email to