-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy path01_christmas_tree_sales.Rmd
52 lines (38 loc) · 1.82 KB
/
01_christmas_tree_sales.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
name: christmastreesales
# Christmas Trees
Here is a simple plot of Christmas Tree Sales in the U.S. The plot shows that artificial tree sales are on the rise, contrasting with declines in real trees. The title plays on the German Christmas Carol "O Tannenbaum", "Oh Christmas Tree" in English. "Wie echt sind deine Blätter?" means "how real are your leaves"; the original text from the carol is "Wie treu sind deine Blätter!" which means "How true your leaves are!"
I also plot the cumulative number of trees purchased of each type, artificial and real, from 2004 to 2014, comparing that to the 2016 U.S. population. Almost one real tree per person was bought over the course of 10 years!
```{r}
library(tidyverse)
```
```{r, echo = F}
dta <- readxl::read_xlsx("raw_data/Christmas tree sales.xlsx") %>%
mutate(`Number of trees sold (millions)` = `Number of trees sold` / 1000000)
```
A random sample from the data set:
```{r, echo = F}
knitr::kable(sample_n(dta, 5), format = "html")
```
---
```{r christmas, eval=F, echo=F}
ggplot(data = dta) +
aes(x = Year) +
aes(y = `Number of trees sold (millions)`) +
geom_point() +
aes(col = fct_rev(`Type of tree`)) +
geom_smooth(method = "lm", se = F) +
scale_color_manual(values =
c("darkgreen", "green")) +
ylim(c(0, 35)) +
labs(col = "") +
labs(title = "Wie echt sind deine Blätter?") +
labs(subtitle = "Real and fake Christmas trees sold in the US | Data Source: Statista | @EvaMaeRey ") +
theme_bw()
```
```{r, echo = F, warning=F, message=F, eval = T, fig.show='hide'}
get_what_save_what <- "christmas"
eval(parse(text = paste(knitr:::knit_code$get(get_what_save_what), collapse = "")))
ggsave(paste0("figures/", get_what_save_what, ".png"), dpi = 300)
```
`r apply_reveal("christmas")`
---