Replace exercice_en.Rmd

parent 01d56d75
......@@ -45,8 +45,8 @@ df <- df[c(2:4)]
df[c(1,2),]
```
## Reproducing Playfair's graph
**!!TODO : perform required transformations in terms of wheat-price & salary**
## 1. Reproducing Playfair's graph
<!-- **!!TODO : perform required transformations in terms of wheat-price & salary** -->
```{r, message=FALSE}
# create a list of colors
my_colors <- list( blue = "#3399e6",
......@@ -65,9 +65,9 @@ ggplot(df, aes(x=Year)) +
# Custom the Y scales:
scale_y_continuous(
# Features of the first axis
name = "Wages",
name = "Wages (in Shillings per week)",
# Add a second axis and specify its features
sec.axis = sec_axis( trans=~.*1.5, name="Wheat Price")
sec.axis = sec_axis( trans=~.*1.5, name="Wheat Price (in Shillings per quarter)")
) +
labs(title = "Evolution of wages and wheat price for English workers (16th to 19th century)") +
theme(plot.title = element_text(hjust = 0.5),
......@@ -75,7 +75,7 @@ ggplot(df, aes(x=Year)) +
axis.title.y.right = element_text(colour = my_colors[["dark"]]))
```
## Alternative representation
## 2. Alternative representation
First, we represent the data as simple dots for both wages and wheat price.
As it is difficult to see the pattern for the wheat values evolution, we use the `stat_smooth()` function that shows a smoothed mean.
......@@ -96,10 +96,10 @@ ggplot(df, aes(x=Year)) +
# Custom the Y scales:
scale_y_continuous(
# Features of the first axis
name = "Wages",
name = "Wages (in Shillings per week)",
# Add a second axis and specify its features
sec.axis = sec_axis( trans=~.*1.5, name="Wheat")
sec.axis = sec_axis( trans=~.*1.5, name="Wheat (in Shillings per quarter)")
) +
labs(title = "Evolution of wages and wheat price for English workers (16th to 19th century)") +
theme(plot.title = element_text(hjust = 0.5),
......@@ -107,4 +107,7 @@ ggplot(df, aes(x=Year)) +
axis.title.y.right = element_text(colour = wheat_color))
```
## 3. Another Representation without an explicit time axis
TBD
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment