generated from jtr13/EDAVtemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathformatting.Rmd
86 lines (52 loc) · 2.02 KB
/
formatting.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Formatting Tips
*You should delete this file from your book and remove `bookdowntips.Rmd` from the `_bookdown.yml` file.
## Code
- Do not show code. This should happen automatically since `echo` is set to `FALSE` in `_common.R`.
## Citations
- Cite all text sources using markdown syntax: $[\text{link text}](\text{url})$
- Cite code sources as comments in your code chunks.
```
# From: https://github.com/pbiecek/ema/blob/master/07-iBreak-Down.Rmd#L255
```
## Math
- Use MathJax / Latex format: [basic intro](https://rmd4sci.njtierney.com/math)
- Enclose in single dollar signs for inline expressions: $a^2 + b^2 = c^2$
- Enclose in double dollar signs for new line centered expressions: $$a^2 + b^2 = c^2$$
- Use [hostmath.com](http://hostmath.com/) for a point and click interface to create LaTeX expressions
## Plots
### Figure size
Set a default plot size by adding:
```
fig.width = 5,
fig.height = 3.5
```
(You can adjust the numbers)
to `knitr::opts_chunk$set()` in `_common.R`.
Then as needed override one or more defaults in particular chunks:
`{r, fig.width=8, fig.height=6}`
In general, faceted plots should have larger sizes.
Examples:
```{r}
library(ggplot2)
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point() + ggtitle("Default plot size (5 x 3.5)")
```
```{r, fig.width = 3, fig.height = 3, fig.cap=""}
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point() + ggtitle("In chunk options: \n `fig.width = 3, fig.height = 3`")
```
## Figure numbers
- Include a chunk label *and* a figure caption `fig.cap` in the chunk options:
```
{r hist1, fig.cap = "Histogram of `Sepal.Width`"}
```
- Refer to the plot with the chunk label:
Figure $\text{\@ref(fig:hist1)}$ shows...
```{r hist1, fig.cap = "Histogram of `Sepal.Width`"}
ggplot(iris, aes(Sepal.Width)) +
geom_histogram(color = "blue", fill = "cornflowerblue")
```
Figure \@ref(fig:hist1) shows the distribution of `Sepal.Width` in the `iris` dataset.
## Resources
(More will be added)
[Rmarkdown for Scientists](https://rmd4sci.njtierney.com/)