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]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to