Skip to content

Would it be better if knitr DID NOT enclose the result of inline commands in R Markdown files with backticks? #244

jeromyanglim opened this Issue May 19, 2012 · 4 comments

3 participants


Currently, knitr converts

`r 2 + 2`



and the Markdown converter then generates


However, I think it would be better default behaviour to just print the result, WITHOUT enclosing the result in backticks (which are in turn converted to code tags).

  • If I don't want the code tags, I have no choice. Whereas if the default behaviour was to not add TAGS, I could just add the tags.
  • I don't think Sexpr adds any formatting. And this is the behaviour that I would expect.
  • In particular, I was trying to write a formula in a blog post that included inline output. However, this didn't work because of the code tags (e.g., $2+2 = r 2 + 2$).
  • Keeping it plain gives the user freedom to do what they want with the resulting output.

Alternative, is there a way of using handles or some other feature to disable the use of <code> tags for inline code in R Markdown?


I don't think knitr is adding this markup. I believe it must be markdown, which is translating inline to code. AFAIK, markdown was not designed for reproducible document writing. So the inline usage was mainly to highlight code, which is why you are seeing the markup.


@ramnathv I updated the issue to clarify my understanding of the role of knitr and the markdown to html program. I'm essentially asking whether the default behaviour in knitr for inline commands should be to just print the result rather than surrounding the result in backticks. I think this would be more flexible.

Also, I imagine you have not seen what R Markdown can do. It supports inline commands now. See the answer to this question.

yihui commented May 21, 2012

sorry, this is not well documented; the solution is to use I(), which means not to wrap my result in any tags; just leave it as-is, e.g. I(2+2)

it is hidden deep in

@jeromyanglim jeromyanglim reopened this May 23, 2012

Thanks @yihui . That works perfectly. I added the details to this question on stack overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.