Tunn
Tunn

Reputation: 1536

R code inside math notation R Markdown

In R Markdown, I can get an inline r code chunk to run inside single $ math notation (only with a * before), but not double $$ math notation:

* $H_o = `r 1 + 1`$

works, but:

$H_o = `r 1 + 1`$

doesn't work, and neither does:

$$H_o = `r 1 + 1`$$

The double $$ is more flexible being able to put math notation on multiple lines, but how can you add inline code chunks inside?

Upvotes: 8

Views: 4357

Answers (1)

Justin
Justin

Reputation: 1410

I ran your example and it worked fine for me! Here is a link to the pdf and github .md documents I generated. And here is a link to the rmarkdown document.

I'm using R 3.4.1, knitr 1.16, and rmarkdown 1.6.

Perhaps you should check your version of rmarkdown and knitr. I have noticed over the years that version updates, and sometimes even using the most recent dev version, can fix a litany of small issues that arise.

Upvotes: 3

Related Questions