简体   繁体   English

R代码和图在Lyx / R / knitr中的位置

[英]Placement of R code and plots in Lyx/R/knitr

I am writing up a short report in Lyx (2.0.6) and I have six chunks of R code (3.0.2) that each generate a plot (ie, six plots). 我正在用Lyx(2.0.6)编写一份简短的报告,我有六个R代码块(3.0.2),每个块都生成一个绘图(即六个绘图)。 The problem is that the plots always shows up at the top of the page whereas I want the plots to always immediately follow the code that produced it. 问题在于,绘图始终显示在页面顶部,而我希望绘图始终紧随生成它的代码。 I have tried the chunk option fig.show="asis" and Documents -> Settings -> float placement -> here definitely, but neither seems to have any effect. 我已经在这里尝试过块选项fig.show =“ asis”和Documents-> Settings-> float placement->,但是似乎都没有任何效果。 Any suggestions? 有什么建议么?

After a bit of experimentation I found that I can get tables and figures generated with R/knitr to behave the way I want if I put the chunks in Lyx floats (Tables and Figures) rather than have knitr generate the floats. 经过一些试验,我发现如果将块放在Lyx浮点数(表格和图形)中,而不是让Knitr生成浮点数,我可以得到用R / knitr生成的表和图形的行为。 The xtable option float=FALSE was used. 使用xtable选项float = FALSE。

您可以为每个带有图形的块或全局将fig.pos="H"添加到knitr选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM