[R] Knitr R - how to draw plot exactly at place of plot function call in output document?
Michu Kom
michu.kom at gmail.com
Mon Jun 6 09:38:08 CEST 2016
My R script run with Knitr generates a statistic summary of electrode pairs
accompanied with plots. The problem is that knitr does not render plots in
correct sections. In section for pair A knitr do not wait for plot and
start to evaluate code for output summary for pair B. So in section B knitr
places plot from section A among printed output summary for pair B.
My function analizePair calculates some statistics and print them out. I
call a ezPlot function inside analizePair function.
knitr::opts_chunk$set(fig.show = 'asis') # 'hold' option is not proper
for my needs
for(pair in pairsLabels)
{
print("----------")
print("Analysing single pair of electrodes...")
print("----------")
print(pair)
analizePair(pairLabel = pair)
print("----------")
print("Analysing pair finished.")
print("----------")
}
I also tried to put Sys.sleep(2) after analizePair, but it do not solve the
problem.
How to force knitr/R to wait until plot is generated and put before
starting next section (next iteration of for loop) ?
[[alternative HTML version deleted]]
More information about the R-help
mailing list