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
[EMAIL PROTECTED] a e'crit :
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.
Try:
x = 1.23456789
format(x, nsmall=20)
# [1] 1.2345678899989009
I've just re-read the question. I
Matthieu Stigler a e'crit :
[EMAIL PROTECTED] a e'crit :
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.
Try:
x = 1.23456789
format(x, nsmall=20)
# [1] 1.2345678899989009
I've just re-read the question.
Actually (after some trials) there is a little problem when faced with
zeros...
getndp(1.0)
[1] 0
Are you sure this isn't what you want? 1.0 is just 1 in disguise, and
round(1.0, 0) is the same as round(1.0, 1) anyway.
Note that I thought on a very different way which was starting
4 matches
Mail list logo