Created
January 1, 2019 02:09
Star
You must be signed in to star a gist
use non-breaking thin space as thousands separator in rmarkdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myNum <- function(n) { | |
# use in markdown with variable some_number: | |
# `r myNum(some_number)` and the thousands separator is a | |
# nonbreaking thin space, which is ISO 30-1 | |
return(prettyNum(n, big.mark=' ')) | |
} |
I've found that this function doesn't work (or no longer works) when inside kable
tables when knitting to pdf. You have to use the unicode character instead of ' '
:
myNum <- function(n) {
# use in markdown with variable some_number:
# `r myNum(some_number)` and the thousands separator is a
# nonbreaking thin space, which is ISO 30-1
return(prettyNum(n, big.mark = "\U2009"))
}
Nice!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't use commas or periods as thousands separator. Use the thin space.