Set global thousand separator on knitr

前端 未结 1 1768
独厮守ぢ
独厮守ぢ 2020-12-28 08:25

I want all the numbers on my knitr report to be formatted as such by default:

format(num, digits = 2, big.mark = \" \", decimal.mark = \",\")
相关标签:
1条回答
  • 2020-12-28 09:15

    As Frank noted, setting a knitr hook such as the following solves the problem:

    knit_hooks$set(inline = function(x) {
      prettyNum(x, big.mark=" ")
    })
    

    It turns out knitr hooks are a great way to tweak the output of R chunks on knitr. It's really worth it to take a look at http://yihui.name/knitr/hooks.

    Source: https://groups.google.com/forum/#!msg/knitr/CnFwvk1Qn1E/WY-Xhf7Ph3AJ

    0 讨论(0)
提交回复
热议问题