Some introductory test
In creating a vignette, these code & output display options are useful:
- no code display, no output
- display code, but not output
- display code with R prompt, but not output
- display code and output
- no code display, just the output
- tasteful display of a data.frame
- tasteful display of a data.frame, no ode
- show a previously created image
1. execute code: no code display, no output
{r label goes here, include=FALSE}
2. execute code, display code, no output
3. show R prompt, execute code, display code, no output
4. display code and output
[1] 4
5. no code display, just the output
## [1] "variant 5"
6. tasteful display of a data.frame
knitr::kable(mtcars[1:5,], caption='mtcars')
mtcars
Mazda RX4 |
21.0 |
6 |
160 |
110 |
3.90 |
2.620 |
16.46 |
0 |
1 |
4 |
4 |
Mazda RX4 Wag |
21.0 |
6 |
160 |
110 |
3.90 |
2.875 |
17.02 |
0 |
1 |
4 |
4 |
Datsun 710 |
22.8 |
4 |
108 |
93 |
3.85 |
2.320 |
18.61 |
1 |
1 |
4 |
1 |
Hornet 4 Drive |
21.4 |
6 |
258 |
110 |
3.08 |
3.215 |
19.44 |
1 |
0 |
3 |
1 |
Hornet Sportabout |
18.7 |
8 |
360 |
175 |
3.15 |
3.440 |
17.02 |
0 |
0 |
3 |
2 |
7. tasteful display of a data.frame, no code, no caption
Mazda RX4 |
21.0 |
6 |
160 |
110 |
3.90 |
2.620 |
16.46 |
0 |
1 |
4 |
4 |
Mazda RX4 Wag |
21.0 |
6 |
160 |
110 |
3.90 |
2.875 |
17.02 |
0 |
1 |
4 |
4 |
Datsun 710 |
22.8 |
4 |
108 |
93 |
3.85 |
2.320 |
18.61 |
1 |
1 |
4 |
1 |
Hornet 4 Drive |
21.4 |
6 |
258 |
110 |
3.08 |
3.215 |
19.44 |
1 |
0 |
3 |
1 |
Hornet Sportabout |
18.7 |
8 |
360 |
175 |
3.15 |
3.440 |
17.02 |
0 |
0 |
3 |
2 |
code chunks
A paragraph here. A code chunk below (remember the three backticks):
## [1] 2
.4-.7+.3 # what? it is not zero!
## [1] 5.551115e-17
graphics
It is easy.
inline code
Yes I know the value of pi is 3.1415927, and 2 times pi is 6.2831853.
math
Sigh. You cannot live without math equations. OK, here we go: \(\alpha+\beta=\gamma\). Note this is not supported by native markdown. You probably want to try RStudio, or at least the R package markdown, or the function knitr::knit2html()
.
nested code chunks
You can write code within other elements, e.g. a list
-
foo is good
strsplit('hello indented world', ' ')[[1]]
## [1] "hello" "indented" "world"
bar is better
Or inside blockquotes:
Here is a quote, followed by a code chunk:
## [1] 100 81 64 49 36 25 16 9 4 1
conclusion
Nothing fancy. You are ready to go. When you become picky, go to the knitr website.