2015-06-30 29 views
1

我正在使用Sweave在R-Studio中創建報告,並且我遇到了問題,即我的老師只接受報告,其中的代碼放置在附錄中。這意味着我需要控制塊輸出的位置(圖形)。chuk輸出的Sweave控制

Sweave有可能嗎?

問候,

+0

你能提供[最小的重複性〔實施例](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)並顯示您的預期輸出?這應該可以通過引用塊和控制輸出來實現,但很難說沒有更多的信息。 – Thomas

+0

也許這可能有幫助嗎? [附錄](http://stackoverflow.com/questions/4362747/print-the-sourced-r-file-to-an-appendix-using-sweave) –

回答

0

這將返回在代碼中的一切。使用\ usepackage {} fancyvrb和\ {VerbatimInput} test.Rnw假設你的文件被命名爲test.Rnw

\documentclass{article} 
\usepackage{fancyvrb} 

\begin{document} 
\SweaveOpts{concordance=TRUE} 

<<my_code_chunk>>= 
2+2 
@ 

\section{Appendix} 
\VerbatimInput{test.Rnw} 

\end{document} 

下面是另一個例子

\documentclass{article} 
\begin{document} 
\SweaveOpts{concordance=TRUE} 
<<my_code_chunk>>= 
2+2 
@ 
\section{Appendix} 

<<>>= 
<<my_code_chunk>> 
@ 

\end{document}