6

I'm producing an introductory R guide for my company. I'm doing a little demo of the R help function (shorthand)

?mean

This is in a knitr chunk:

<<eval=FALSE>>=
?mean
@

Output:

`?`(mean)

I would prefer that it outputs it as I type it, i.e. ?mean not ?(mean) (with backticks). Does anyone know of a workaround for this?

Thanks!

Apologies if this is a repeat question or has a very simple solution - it's not an easy topic to search for!

dynamo
  • 2,988
  • 5
  • 27
  • 35
  • 1
    There a bazillion examples in the knitr documentation / site. Have you looked there? Also, if you want something _verbatim_ and unchanged by `knitr`, you could just use pure LaTeX in that particularly expression and not invoke knitr. – Dirk Eddelbuettel Feb 04 '13 at 13:29
  • I've looked, but as I said, I don't really know how to search for that. I could do it verbatim, but I want to keep the way knitr formats the chunk. I guess that best hacky way to solve this is to copy the tex chunk that knitr produces and replace `?(mean)` with `?mean` manually. – dynamo Feb 04 '13 at 13:43
  • Look at the existing vignettes on your system, find one you like and then at _its_ sources. – Dirk Eddelbuettel Feb 04 '13 at 14:44

1 Answers1

4

Setting tidy=FALSE will give you the result you're looking for:

<<eval=FALSE, tidy=FALSE>>=
?mean
@

Output

?mean
Josh O'Brien
  • 159,210
  • 26
  • 366
  • 455