我是R
的新手,Sweave
的新手,我正在試驗圖形。下面是一個示例代碼:R/Sweave:前綴和圖形文件命名
\documentclass[a4paper]{article}
\usepackage{Sweave} %%%%%%
\SweaveOpts{eps=true}
\begin{document}
<<echo=FALSE>>=
test.frame<-data.frame(year=8:11, value= c(12050,15292,23907,33991))
@
\SweaveOpts{prefix.string=Evolution}
<<label=amount,echo=FALSE,results=hide>>=
postscript('doudou.eps',
width=6, height=7,
colormodel="cmyk",
family = "ComputerModern")
with(test.frame,plot(year, value))
dev.off()
@
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=1\textwidth,angle=90]{doudou.eps}
\end{center}
\end{figure}
\end{document}
What I want to do above?
若要在EPS
文件,我將讓我可以在Sweave
文件本身\includegraphics
命令手動控制。
,我試圖給一個適當的文件名圖:前綴Evolution
和標籤amount
,使得產生的EPS
數字將被命名爲Evolution-amount.eps
。
What is going wrong?
正如你所看到的,我在R
postscript
選項即doudou.eps
插入一個文件名。如果我不這樣做,一個名爲Rplots.ps
的文件由R
創建。
所以我的代碼很好地忽略了我想給我的圖形文件的前綴和標籤。
而且我明確地問以後由\includegraphics
把doudou.eps
。
How I want it to be?
爲了能夠有前綴和標籤,因爲我在圖中的文件名如上所述,雖然我還有過在Sweave
文件\includegraphics
命令手動控制。這可能嗎?
What is the use of this?
說我寫文章,我有不同的部分數字。因此,這將是不錯的東西,如:
\SweaveOpts{prefix.string=Paper2}
<<label=section2,echo=FALSE,results=hide>>=
和例如我在postscript
選項指定:model.eps
。
那麼這個數字將被命名Paper2-section2.model.eps
例如。這是可行的嗎?
而且我需要以某種方式手動把這個名字?在下面的\includegraphics
命令中。
非常感謝......
更新:09年12月2011年
與cbeleites的幫助下,緊密的解決方案是:
\documentclass[fleqn, a4paper,12pt]{article}
\usepackage[latin1]{inputenx}
\usepackage[T1]{fontenc}
\usepackage{Sweave} %%%%%%
\SweaveOpts{eps=TRUE}
\begin{document}
<<echo=FALSE>>=
test.frame<-data.frame(year=8:11, value= c(12050,15292,23907,33991))
@
\SweaveOpts{prefix.string=Paper2}
<<label=section2, echo=FALSE,results=hide>>=
ps.options (width=6, height=7, colormodel="cmyk", family = "ComputerModern")
@
<<label=section2, fig=TRUE, include = TRUE, echo=FALSE>>=
with(test.frame,plot(year, value))
@
\end{document}
在編譯時我得到的EPS和名爲Paper2-section2的PDF文件。這和我想的一樣接近。
請不要在問題主體中添加對問題的答案。這變得非常混亂。 SO上的每個問題都應該成爲一個問題。 – Andrie