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

Ulrik Stervbo ulrik.stervbo at gmail.com
Tue Jun 7 07:51:36 CEST 2016


Hi Michu,

it is not I problem I am familiar with, sorry. Maybe someone else on this
list or at the knirt google group can help you further.

Best,
Ulrik

On Mon, 6 Jun 2016 at 10:36 Michu Kom <michu.kom at gmail.com> wrote:

> Hello,
>
> HTML looks much nicer :) ... but still problem is not solved :/ still
> having mixed sections and plots.
>
> Thank you for your advice,
> Michu
>
> 2016-06-06 10:04 GMT+02:00 Ulrik Stervbo <ulrik.stervbo at gmail.com>:
>
>> 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