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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -