R Language R in LaTeX with knitr R in Latex with Knitr and Inline Code Chunks


Knitr is an R package that allows us to intermingle R code with LaTeX code. One way to achieve this is inline code chunks. This apporach is demonstrated below.

# r-noweb-file.Rnw
This is an Rnw file (R noweb).  It contains a combination of LateX and R.

print("This is an R Code Chunk")
x <- seq(1:10)

Above is an internal code chunk.
We can access data created in any code chunk inline with our LaTeX code like this.
The length of array x is \Sexpr{length(x)}.