Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no sci format of very small numbers #1187

Closed
mkapplebee opened this issue Apr 2, 2016 · 2 comments
Closed

no sci format of very small numbers #1187

mkapplebee opened this issue Apr 2, 2016 · 2 comments
Milestone

Comments

@mkapplebee
Copy link

I am very new to R markdown, but I am trying to write a report with it in HTML format with tables. Some of my tables include pvalues, some of which are very small - so the exponent associated with them is important. I would like to use knitr/kable, but my padj values are only showing as "0". Here is some code with a modified 'iris' table that shows the problem - compare column 'sml' between the kable version and regular "print" version -

library(knitr)
options(scipen=-20)
sml<-iris[,1]*10^-12  #these are very small, but not 0
lrg<-iris[,2]*10^12  # these are analogously large
y<-cbind(sml,lrg,iris[,3:5])

kable(y[1:10,])    #sml is converted to 0, in scientific format, but lrg retains its correct reported value
y[1:10,]              # sml is correctly reported in scientific format

screenshot of the output I get:
test1-screenshot

I am using R 3.2.3, Rstudio Version 0.99.451, and I just checked that I have the latest update to knitr - but I still get this problem.

@yihui yihui added this to the v1.13 milestone Apr 5, 2016
@yihui
Copy link
Owner

yihui commented Apr 5, 2016

That is because the numbers are rounded to 7 decimal places by default. You can use a larger digits value, e.g.

kable(y[1:10,], digits = 20)

But I think a P-value as small as 10^-12 is basically 0.

@yihui yihui closed this as completed Apr 5, 2016
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants