I would like the code in paragraphs to be consistent with the code shown in code chunks.
For example:
<p>
The formula method for a linear model
is <code>lm(y~x, data = dat)</code>.
For our data the results are:
</p>
<!--begin.rcode
lm(y~x, data = dat)
end.rcode-->
It would be nice to use something besides <code>
inline and get the same formatting as the chunk's code.
I'm using knitr
:
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
other attached packages:
[1] knitr_1.2
loaded via a namespace (and not attached):
[1] digest_0.6.3 evaluate_0.4.3 formatR_0.7
[4] stringr_0.6.2 tools_3.0.1
Thanks,
Max
You could try
<!--rinline deparse(substitute(lm(y~x, data = dat))) -->
. (Seems that the syntax highlighting isn't working).You can redefine the
inline
hook, and write your inline code as character strings. Below is a minimal example (make sure you are using the latest versions of all R packages):The key is to do syntax highlighting via
highr::hi_html()
, and here is the output: