以前一直傻傻的 用 \begin{verbatim} 或者 listing 的方式在文章中加 R 代码 然后再手工 include 结果的方式,现在知道了 Sweave,终于可以结束这段傻 不楞登的过程直接自动化了。
\documentclass[a4paper, 12pt]{article}
\begin{document}
\title{emacs \& Sweave}
\author{Wang Jun}
\maketitle
\section{Now begins R Sweave test}
First Save this file as example.Rnw
Then run Sweave("example") in R
Compile the generated tex file example.tex with pdflatex or xelatex (I prefer XeLeTeX)
Here you got the Sweaved R script
%%%%%%%%%%%%% Here begins the Main Content
This is just a simple example
<<>>=
library(maps)
library(mapdata)
###map("china")
x=rnorm(100)
y=rnorm(100)
lm(y~x)
@
Now that you have tried Sweave, how does it perform?
\end{document}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you have a gist with multiple files, you can include files one at a time by adding the name after the gist id.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters