-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintro-r.qmd
41 lines (33 loc) · 1.15 KB
/
intro-r.qmd
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
# Rendering R documents
This is a book created from markdown and executable code.
See @knuth84 for additional discussion of literate programming.
## Running R code
```{r}
library(palmerpenguins)
library(ggplot2)
ggplot2::theme_set(ggplot2::theme_minimal())
```
## Example graph using penguins dataset
```{r}
#| label: fig-penguins
#| fig-cap: "Flipper length and body mass for Adelie, Chinstrap and Gentoo Penguins"
mass_flipper <- ggplot(data = penguins,
aes(x = flipper_length_mm,
y = body_mass_g)) +
geom_point(aes(color = species,
shape = species),
size = 3,
alpha = 0.8) +
scale_color_manual(values = c("darkorange","purple","cyan4")) +
labs(title = "Penguin size, Palmer Station LTER",
subtitle = "Flipper length vs. body mass",
x = "Flipper length (mm)",
y = "Body mass (g)",
color = "Penguin species",
shape = "Penguin species") +
theme(legend.position = c(0.2, 0.7),
plot.title.position = "plot",
plot.caption = element_text(hjust = 0, face= "italic"),
plot.caption.position = "plot")
mass_flipper
```