| 1 |
--- |
| 2 |
title: "Not An Introduction to knitr" |
| 3 |
author: "Yihui Xie" |
| 4 |
date: "`{r} Sys.Date()`" |
| 5 |
output: |
| 6 |
html: |
| 7 |
meta: |
| 8 |
css: ["@default"] |
| 9 |
vignette: > |
| 10 |
%\VignetteEngine{litedown::vignette} |
| 11 |
%\VignetteIndexEntry{Not an Introduction to knitr} |
| 12 |
--- |
| 13 |
|
| 14 |
The **knitr** package is an alternative tool to Sweave based on a different |
| 15 |
design with more features. This document is not an introduction, but only serves |
| 16 |
as a placeholder to guide you to the real manuals, which are available on the |
| 17 |
package website <https://yihui.org/knitr/> (e.g. the [main |
| 18 |
manual](https://yihui.org/knitr/demo/manual/) and the [graphics |
| 19 |
manual](https://yihui.org/knitr/demo/graphics/) ), and remember to read the help |
| 20 |
pages of functions in this package. There is a book "Dynamic Docuemnts with R |
| 21 |
and knitr" for this package, too. |
| 22 |
|
| 23 |
Below are code chunk examples: |
| 24 |
|
| 25 |
```{r show-off} |
| 26 |
options(digits = 4) |
| 27 |
rnorm(20) |
| 28 |
fit = lm(dist ~ speed, data = cars) |
| 29 |
b = coef(fit) |
| 30 |
``` |
| 31 |
|
| 32 |
```{r echo=FALSE} |
| 33 |
summary(fit)$coefficients |
| 34 |
``` |
| 35 |
|
| 36 |
The fitted regression equation is $Y=`{r} b[1]`+`{r} b[2]`x$. |
| 37 |
|
| 38 |
```{r graphics, fig.cap='A scatterplot with a regression line.'} |
| 39 |
par(mar=c(4, 4, 1, .1)) |
| 40 |
plot(cars, pch = 20) |
| 41 |
abline(fit, col = 'red') |
| 42 |
``` |
| 43 |
|
| 44 |
## References |
| 45 |
|
| 46 |
```{r, echo=FALSE, results='asis', warning=FALSE} |
| 47 |
print(citation('knitr'), style = 'html') |
| 48 |
``` |