2

I have the following file with tab separator:

Motif Name  P-value
Fra1    1e-613
Atf3    1e-585
Fra2    1e-576
JunB    1e-559
BATF    1e-550
AP-1    1e-537
Fosl2   1e-513
Jun-AP1 1e-473
Bach2   1e-193

When I try to read it with this code:

infile <- "~/Desktop/test.csv"
dat    <- readr::read_delim(infile, delim = "\t", col_types = "cd")  
dat 

I get this value:

 `Motif Name` `P-value`
  <chr>            <dbl>
1 Fra1            1e-307
2 Atf3            1e-307
3 Fra2            1e-307
4 JunB            1e-307
5 BATF            1e-307
6 AP-1            1e-307
7 Fosl2           1e-307
8 Jun-AP1         1e-307
9 Bach2           1e-193

Note that readr round up the number from 1e-613 to 1e-307, etc. How can I make it to preserve the initial value?

littleworth
  • 4,781
  • 6
  • 42
  • 76
  • 2
    From [`?.Machine`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/zMachine.html) (and the values see in `str(.Machine)`), note that the *"smallest non-zero normalized floating-point number"* in base R is `.Machine$double.xmin` which is `2.23e-308`. Sorry, I don't think you're going to easily get your `1e-613` without a bit more work. (The alternative to returning `1e-307` is that it will effectively be zero, see `1e-613 > 0` as false.) – r2evans Dec 01 '21 at 05:20
  • 2
    From your data sample, it looks like the exponent is the relevant quantity, so taking a poor man’s log10 by just removing `1e-` (i.e. read as string, then do some regex) could be a workaround. – All Downhill From Here Dec 01 '21 at 07:07

0 Answers0