Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 574
Tunn Avatar asked Jul 27 '17 20:07

Tunn


1 Answers

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.

like image 114
Justin Avatar answered Sep 25 '22 07:09

Justin