knitr's kable is printing 2.29e-30 as "0"

Viewed 1197

CODE:

# some data
dat <-
  data.frame(
    log2fc = c(0.28, 10.82, 8.54, 5.64, 8.79, 6.46),
    pvalue = c(0.00e+00, 2.29e-30, 7.02e-30, 4.14e-29, 1.86e-28, 1.78e-27)
  )

# observe in markdown format
knitr::kable(dat, format="markdown")

OUTPUT:

| log2fc| pvalue|
|------:|------:|
|   0.28|      0|
|  10.82|      0|
|   8.54|      0|
|   5.64|      0|
|   8.79|      0|
|   6.46|      0|

PROBLEM:

The problem with the output is that, it is rendering the last column pvalue as zeros. But I would want to retain the same format as I see in my dataframe. How do I do that ? I've tried several solutions from various threads but nothing seems to work. Can someone point me to the right direction ?

Please do not suggest me to convert the pvalue column into a character vector. That is a quick and dirty solution that works, but I don't want to do that because:

  1. I don't want to mess around with my dataframe.
  2. I am interested in the reason for why the scientific format of the last column is not being retained while printing it in markdown.
  3. I have many tables each with various columns with scientific format, I am looking for a way that automatically handles this issue.
1 Answers
Related