1

How can we correctly calculate the following?

df <- data.frame(logp=c(-2,-200,-600))
10^(df$logp)
# [1]  1e-02 1e-200  0e+00

This will give us 0 in logp=-600. Can we handle this problem?

user20650
  • 24,654
  • 5
  • 56
  • 91
user224050
  • 317
  • 3
  • 10
  • Perhaps you could calculate it on the log scale (`log(10)* df$logp`) or use a high precision library (`10^Rmpfr::mpfr(df$logp, 120`) -- depends on what you want to do with it. – user20650 Jan 09 '21 at 16:13
  • The function `.Machine` provides a list of numerical characteristics and the smallest non-zero normalized floating-point number ~1E-308 – Dave2e Jan 09 '21 at 16:16
  • ?duplicate: https://stackoverflow.com/questions/5802592/dealing-with-very-small-numbers-in-r – user20650 Jan 09 '21 at 16:38

0 Answers0