Search code examples
rroundingdigits

R shows too few digits


I wanted to calculate that term:

(21000*(1.022^7-1))/(1.022-1)

R tells me, it's 157065.7. This was my answer to a task that I had to solve. It was stated that this answer is not correct, the correct answer should be 157065.67. Then I calculated this with my calculator on my smartphone and indeed, the solution was 157065.67034. I am really wondering what is wrong with R and whether I can change some options. I've tried options()$digits but that's 7, this can't be the problem...


Solution

  • Use options(digits = 15). Note that this changes globally the format. Also, the number of digits indicates all the digits (before and after the decimal separator).