I was doing some calculations and I noticed that when I add pipes it outputs a wrong result. It is the first time I encounter this and I would like to know why it happens to avoid this situation in the future.
# Making the operations separately gives the correct result.
0.58*(1-0.58) # 0.2436
sqrt(0.2436) # 0.4935585
# Adding all calculations in the same line works.
sqrt(0.58*(1-0.58)) # 0.4935585
# Use %>% doesn't give the right result.
0.58*(1-0.58) %>% sqrt() # 0.375883
# The issue doesn't happen when in a df or tibble
tibble(a = c(0.2436)) %>%
mutate(b = sqrt(a))
# A tibble: 1 × 2
# a b
# <dbl> <dbl>
# 1 0.244 0.494
Thank you,