I regularly embed R code into Rnw files and use knitr
to convert the Rnw file to a tex file and then pdf. The upside of this approach is that is increases reproducibility. The downside is that it interrupts the flow of the writing process.
For example, assume the following is part of the results section of a research paper:
I compared the means of group A and group B. The mean of group A was
\Sexpr{mean(groupA)}
. The mean of group B was\Sexpr{mean(groupB)}
. (the following couple of sentences then place the two means in context, interpret the value of the two means and explain the relevance of the size of their difference)
In order to place the means in context, interpret their value and explain the relevance of their difference, I need to be able to see the actual value of each mean. But I cannot see the value of each mean without running knitr
to convert to tex and then pdf, which fragments and inhibits the flow of the writing process.
Do people use any methods that allow R code to run within the Rnw file. In the above example, is there a way of showing of the value of each mean within the Rnw file, such that the flow of writing isn't interrupted? Or are there any workarounds?