Home > Net >  R calculates wrong?
R calculates wrong?

Time:10-15

How can that be?

> mode(daten[1,16])
[1] "numeric"
> mode(weku)
[1] "numeric"
>
> weku
[1] 10.47855
> daten[1,16]
[1] 814995955
> daten[1,16]/weku
[1] 77777557
>
> 814995955/10.47855
[1] 77777551
> 

I don't understand this. How can I get the correct calculation?

CodePudding user response:

daten[1,16]/weku is correct.

R does not display all of the decimal values it stores internally. What is printed on the console is controlled by options("digits").

For example, compare print(pi), print(pi, digits=10), and print(pi, digits=22).

CodePudding user response:

thanks, yes that is correct. I have read the values with

read.csv(...)

and this expanded the precision with options("digits") from 5 to 20 as

 option("digits")

said. But it wasn_t shown in the output. So R calculates correct :-)

Thanks, Christian

  • Related