[R] Knitr R - how to draw plot exactly at place of plot function call in output document?

Ulrik Stervbo ulrik.stervbo at gmail.com
Mon Jun 6 10:04:21 CEST 2016


Hi Michu,

What document type do you generate? I usually make just html and have no
problems. If you create a pdf, please remember this is done through LaTeX
and your problem could arise from the floats of LaTeX.

For other output I have no idea.

Hope this helps
Ulrik

Michu Kom <michu.kom at gmail.com> schrieb am Mo., 6. Juni 2016 09:41:

> 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 at 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list