How to have R code (R chunk) inline with my text?
Example:
Please install the package by using install.packages(\"ISwR\")
wher
Following a suggestion from Yihui,
\documentclass{article}
<<setup, include=FALSE>>=
knit_hooks$set(inline = function(x) {
if (is.numeric(x)) return(knitr:::format_sci(x, 'latex'))
knitr:::hi_latex(x)
})
@
\begin{document}
Please install the package by using \Sexpr{'install.packages("ISwR")'}.
\end{document}
You can use the 3 backticks ``` if you want the encapsulated code NOT to be executed inline . E.g.
There were ```nrow(cars)``` cars studied