2017-06-22 20:37:27
可重复性是科学研究的基本要求
\(\LaTeX\)之父Donald E. Knuth (1992)提出的编程范式,即按照写作逻辑思路和文学章-节结构组织文档文本和程序代码。自然语言和程序语言交织在同一篇文档中,通过特定的标志符号分割开:
tangle(绕)命令: 编译执行程序语言部分,供计算机释读weave(织)命令:格式化编译自然语言部分,供人类阅读文学化编程范式与现代软件工程最优实践不甚相符(很多坑)
Sweave,基于\(\LaTeX\)语法<<块名>>=标示代码块的起始@标示文本段落的起始\documentclass{article}
\begin{document}
\title{Test Doc}
\author{Me}
\maketitle
\section*{R Markdown}
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word
documents. For more details on using R Markdown see \href{http://rmarkdown.rstudio.com}.
When you click the \textbf{Knit} button a document will be generated that includes both content as well as
the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
<<cars>>=
summary(cars)
@
\section*{Including Plots}
You can also embed plots, for example:
<<pressure, echo=FALSE>>=
plot(pressure)
@
Note that the \texttt{echo = FALSE} parameter was added to the code chunk to prevent printing of the R code
that generated the plot.
\end{document}
我们将跳过Sweave大坑,直接基于knitr学习开发自动化报告
---
title: "Test Doc"
author: Me
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word
documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the
output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that
generated the plot.
Thank you!