I need to run knit2html
on the command line using Rscript
. I tried the following code and it works
Rscript -e "(knitr::knit2html(text = '## good', fragment.only = TRUE))"
However, when I introduce R code chunks (or anything involving backticks), the process hangs. So the following does NOT work
Rscript -e "(knitr::knit2html(text = '## good\n `r 1 + 1`',fragment.only = T))"
For the purpose of my use, I only have access to the contents and hence can NOT pass a file to knit2html
, which I know will work.
My question is how do I make this work. I know the problem is the backticks and I have tried looking at escaping them, but nothing seems to be working.