0

Take the following piece of code:

library(dplyr)

x <- c(8.98)
t <- tibble(x)

t %>% 
  mutate(y = map_dbl(1:1, ~ slice(t,.x) %>% pull(.,x) %>% sqrt())) %>% 
  mutate(across(2,round,3))

Its output is:

# A tibble: 1 × 2
      x     y
  <dbl> <dbl>
1  8.98  3.00

However, the code round(sqrt(8.98),3) produces 2.997, while, in the tibble, the result is 3.00.

Should not both results be exactly the same? Is this a bug or something we should be expecting?

PaulS
  • 21,159
  • 2
  • 9
  • 26
  • 2
    According to the answer of above question you can set `options(pillar.sigfig = 4)` – maydin Sep 15 '21 at 13:50
  • Thanks! It is a bit annoying that one should care about significant digits when data.frames manage those automatically. – PaulS Sep 15 '21 at 14:11

0 Answers0