R markdown: Accessing variable from code chunk (variable scope)

knitr, r, r-markdown

Solution

Yes. You can simply call any previously evaluated variable inline.

e.g. If you had previously created a `data.frame` in a chunk with `df <- data.frame(x=1:10)`

`r max(df$x)`

Should produce

10

Problem

In R markdown (knitr package), can I access a variable within the body of the document that was calculated in a code chunk?

Original source

Related problems