r - Using a half-space as a big mark for knitr output -
i number 50000
printed in knitr document half-space thousands separator. in latex use 50\,000
, , knitr print via sexpr
command. is, function reformat
when used in following
\documentclass{standalone} \begin{document} <<>>= num <- 50000 @ number \sexpr{reformat(num)}. \end{document}
prints 50 000 half space. problem face using formatc
doesn't seem allow correct number of backslashes
formatc(num, format = "f", big.mark = "\,") error: '\,' unrecognized escape in character string starting ""\," formatc(num, format = "f", big.mark = "\\,") [1] "50,000.0000" formatc(num, format = "f", big.mark = "\\\,") error: '\,' unrecognized escape in character string starting ""\\\,"
what's correct function in place of reformat
?
both roland , baptiste's solutions work fine:
reformat <- function(num) formatc(num, format = "f", big.mark = "\\\\,") reformat <- function(num) formatc(num, format = "f", big.mark = "\u2009")
Comments
Post a Comment