简体   繁体   中英

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). 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. 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. The xtable option float=FALSE was used.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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