Good morning,
I am writing a document in Rmarkdown and I would like to format all the output tables so that I can have "10 000" rather than "10000" in my HTML rendering.
I work with the kableExtra package mainly. Do you know if there is a special function to do this ?
I tried this :
kable(tableau_ST_CST, big.mark = " ") %>% kable_styling(full_width = F)
But it doesn't work.
You can use prettyNum
:
library(tidyverse)
library(knitr)
tibble(nums = 10000:10010) %>%
mutate(nums = prettyNum(nums, big.mark = " ")) %>%
kable()
|nums |
|:------|
|10 000 |
|10 001 |
|10 002 |
|10 003 |
|10 004 |
|10 005 |
|10 006 |
|10 007 |
|10 008 |
|10 009 |
|10 010 |
Other options include formatC
, format
(both have the same format), or simply using regex (str_replace_all("100000", pattern = "(\\d)(?=(\\d{3})+$)", "\\1 ")
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With