How to use non-breaking spaces as thousands separator in RMarkdown Word output?

673 Views Asked by At

I am using RMarkdown to create a Word document that contains several sentences with numbers inserted to them as inline R chunks. I would like to use non-breaking spaces as thousands separator, but cannot seem to find a way to do this. I have found solutions for HTML and PDF outputs, but not for Word output.

---
output: word_document
---

This is a long sentence with some numbers, so I would like to use non-breaking spaces as thousands separator. For instance, in the number `r formatC(1234, big.mark = " ")`.

Any help would be much appreciated.

2

There are 2 best solutions below

0
user2554330 On

You can input the non-breaking space using its Unicode escape, i.e. formatC(1234, big.mark = "\ua0").

0
Poza On

Another way to do it is "\ ". However, this does not always work.

When does it work? Within the normal Markdown-text.

When does it not work? If you use it within a chunks' cat-command or paste-command.

I don't know why, though.

So better stay with "\ua0".