我正在尝试使用knitr和pandoc转换为PDF时控制绘图的位置.我的.Rmd文件看起来像这样:
# My report
Some text some text some text some text some text some text some text some text some text
```{r myplot, echo=FALSE, fig.pos="placeHere", results='hide'}
library(ggplot2)
ggplot(mtcars, aes(mpg, drat)) + geom_point()
```
Some text some text some text some text some text some text some text some text some text
\usepackage{graphicx}
\begin{figure}[placeHere]
\centering
\includegraphics[width=0.5\textwidth]{placeHere}
\end{figure}
Some text some text some text some text some text some text some text some text some text
Run Code Online (Sandbox Code Playgroud)
我正在使用此处提供的功能转换为PDF:http://quantifyingmemory.blogspot.co.uk/2013/02/reproducible-research-with-r-knitr.html
如何在第二和第三块文本之间放置图?乳胶代码目前无法正常工作. …
我正在使用knitr(1.9.5和1.9.17)和rmarkdown(0.5.3.1),并希望在pdf输出中保持数字位置.fig.pos="H"使用chunk选项时,生成的pdf文件正常工作.
但是,fig_caption: yes在yaml标题中设置时,图形位置不会保持.
我该如何解决这个问题?谢谢你的任何建议.
编辑:
在了解乳胶的漂浮环境之后.我将float包添加到标题中.
\usepackage{float}
Run Code Online (Sandbox Code Playgroud)
但生成的tex文件总是htbp在figure环境fig.pos中使用任何选项.手动切换htbp到之后H,所有数字的位置都保持不变.
这是我的rmd文件示例:
---
title: "Untitled"
output:
pdf_document:
fig_caption: yes
includes:
in_header: mystyles.sty
---
# Section 1
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of …Run Code Online (Sandbox Code Playgroud) 我正在努力使用RStudio在knitr中使用stargazer输出.例如,我将下面的代码粘贴到.Rmd文件中,然后单击"编织HTML".[和]之间的第一个块呈现为方程式.第二个街区来自观星者.它仍然是代码.当我将第二个块(少于[和]]粘贴到Sweave文件中然后单击"编译为PDF"时,代码将呈现为表格.我安装了MikTex和Stargazer的第3版.
在单击编译PDF时,将stargazer或xable表插入knitr文档的答案 适用于Sweave文件(Rnw).在Rmd文件中,单击Knit HTML时不会呈现tex.
如何将stargazer输出放入Rmd文件,以便Knit HTML将乳胶代码转换为表格?(我是Latex的新手,我不确定我可以删除哪些代码,所以请为长段道歉.)
\[
\begin{aligned}
\dot{x} & = \sigma(y-x) \\
\dot{y} & = \rho x - y - xz \\
\dot{z} & = -\beta z + xy
\end{aligned}
\]
\[
\documentclass{article}
\begin{document}
% Table created by StarGazer v.3.0.1 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Sun, Feb 03, 2013 - 11:34:52 AM
\begin{table}[htb] \centering
\caption{}
\label{}
\footnotesize
\begin{tabular}{@{\extracolsep{5pt}}lc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
& \multicolumn{1}{c}{\textit{Dependent variable:}} \\
\cline{2-2}
\\[-1.8ex] & Rate …Run Code Online (Sandbox Code Playgroud)