UPDATE: Seems like my question is actually a very near duplicate of this question and according to that thread, there is currently no "easy" solution. However, that question is over a year old now, and the time may have changed (one can hope!).
My original question follows:
I'm thinking that I need some kind of mechanism to re-order the text and or R
chunks in the document as it is being knit. What I want to be able to do is to write an "article" style document with an abstract and summary at the beginning, before I get into any R
code, but that contains "forward"-references to things that will be calculated in the R
code.
So my exec summary at the beginning might be
We found a `r final_correlation/100`% correlation between x and y...but "final_correlation" will be calculated at the back end of the document as I go through all of the steps of the reproducible research.
Indeed, when I read about reproducible research, I often see comments that the documentation can often be better presented out-of programming sequence.
I believe that in other literate programming frameworks the chunks can be tangled into a different order from that in which they were presented. How can I achieve that in knitr
? Or is there some other completely different workflow or pattern I could adopt to achieve the outcome I want?