Monday, 15 April 2013

How do I present a variable out of sequence in R markdown? -



How do I present a variable out of sequence in R markdown? -

i preparing .rmd document begins executive summary. include inline r code nowadays few of key results front; however, results calculated part of body later in document.

is there way nowadays result in rendered document out of order/sequence actual calculation?

you utilize chunk reuse in knitr (see http://yihui.name/knitr/demo/reference/). here set chunks analyze first not create output, output summary, details. here quick markdown knitr code show this:

```{r chunk1, echo=false, results='hide'} x <- rnorm(1) x ``` value of x `r x`. ```{r chunk2, ref.label='chunk1', echo=true, results='markup', eval=2} ```

note code evaluated twice unless take steps prevent (the eval=2 in example).

another alternative create 2 kid documents, first runs main code , creates output, sec creates summary. in parent document include summary first, detail part. think need run knitr on these hand in right order, automatic kid document tools run in wrong order.

r markdown

No comments:

Post a Comment