When you’re working on extremely small floating numbers in R (such as when you have strong p-values), there are a few options.
- Rmpfr package
- Parse the string of values in scientific notation. Let’s say you have small values in
Pcolumn in a dataframe
dfand those numbers are represented as
1e-400etc. Then, you can run something like this to parse and compute the
df %>% separate( p_value, c("P_base", "P_exp"), sep = "e", remove = F, fill = "right" ) %>% replace_na(list(P_exp = "0")) %>% mutate(log10P = log10(as.numeric(P_base)) + as.numeric(P_exp))