如何确定代码在Sweave中的位置?

问题描述 投票:-1回答:1

我正在使用弯曲来绘制图,我想固定R代码的位置而不固定图形的位置,这就是说我想保持代码在文本中的位置,但是图形是浮动的,我该怎么办? ?谢谢

它推测不清楚,所以我将代码放在这里:

text before the figure

\begin{figure}
<<smokefig, fig.width=3, fig.height=3>>=
tabSmoke<-table(ps$smoke)[2:5]
par(mar = c(2, 4.1, 0.1, 0.1))
with(ps,barplot(100*tabSmoke/sum(tabSmoke),ylim=c(0, 110), las = 2, 
                cex.axis = 0.75,cex.names = 0.75,col = c("pink","lightblue")))
@
\caption{Pourcentages des fumeurs et non-fumeurs selon les quatre modalités}
\end{figure}

text after the figure

我想让R代码出现在行之间,例如

text before the figure

tabSmoke<-table(ps$smoke)[2:5]
par(mar = c(2, 4.1, 0.1, 0.1))
with(ps,barplot(100*tabSmoke/sum(tabSmoke),ylim=c(0, 110), las = 2, 
                cex.axis = 0.75,cex.names = 0.75,col = c("pink","lightblue")))

text afther the figure

然后图形可以出现在任何想要的位置但事实证明,代码与图形浮动在一起,并以如下形式一起出现在下一页:output of code linesoutput of figure

这是我在标题中添加的内容,以防可能有用

\documentclass[10pt]{article}
\usepackage{geometry}
\geometry{a4paper,scale=0.75}
\author{me}
\title{title}
\begin{document}
r sweave
1个回答
0
投票

您说您正在使用Sweave。从所发布的内容尚不清楚,是指R中的Sweave()函数,还是Sweave中的knitr格式。后者要容易得多。如果尚未使用它,则应切换到它。

© www.soinside.com 2019 - 2024. All rights reserved.