Commit 647e37b0 authored by aaaaaa's avatar aaaaaa

version finale pour export pdf

parent 56e5d1ea
--- ---
title: "Etude du pouvoir d'achat des ouvriers anglais du XVIe au XIXe siècle" title: "Etude du pouvoir d'achat des ouvriers anglais du XVIe au XIXe siècle"
author: "Votre nom" date: "Last edited `r format(Sys.Date(), '%d %B %Y')`"
date: "La date du jour" output:
output: html_document pdf_document:
toc: true
--- ---
...@@ -15,7 +16,10 @@ knitr::opts_chunk$set(echo = TRUE, fig.dim=c(10,5)) ...@@ -15,7 +16,10 @@ knitr::opts_chunk$set(echo = TRUE, fig.dim=c(10,5))
[William Playfair](https://fr.wikipedia.org/wiki/William_Playfair) était un des pionniers de la présentation graphique des données. Il est notamment considéré comme l'inventeur de l'histogramme. Un de ses graphes célèbres, tiré de son livre *"A Letter on Our Agricultural Distresses, Their Causes and Remedies"*, montre l'évolution du prix du blé et du salaire moyen entre 1565 et 1821. [William Playfair](https://fr.wikipedia.org/wiki/William_Playfair) était un des pionniers de la présentation graphique des données. Il est notamment considéré comme l'inventeur de l'histogramme. Un de ses graphes célèbres, tiré de son livre *"A Letter on Our Agricultural Distresses, Their Causes and Remedies"*, montre l'évolution du prix du blé et du salaire moyen entre 1565 et 1821.
Le but de ce document est de reproduire dans un premier temps le graphique produit par William Playfair, puis de tenter de l'améliorer pour faire ressortir des informations plus pertinentes. Le but de ce document est de reproduire dans un premier temps le graphique produit par William Playfair, puis de tenter de l'améliorer pour faire ressortir des informations plus pertinentes.
![Graphe de Playfair](https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Chart_Showing_at_One_View_the_Price_of_the_Quarter_of_Wheat%2C_and_Wages_of_Labour_by_the_Week%2C_from_1565_to_1821.png/640px-Chart_Showing_at_One_View_the_Price_of_the_Quarter_of_Wheat%2C_and_Wages_of_Labour_by_the_Week%2C_from_1565_to_1821.png) ```{r echo=FALSE, out.height='75%', out.width='75%'}
knitr::include_graphics("playfair_chart.png")
```
### Chargement des libraries utilisées ### Chargement des libraries utilisées
...@@ -33,7 +37,8 @@ Celles-ci ont été déduites par numérisation et sont disponibles [ici](https: ...@@ -33,7 +37,8 @@ Celles-ci ont été déduites par numérisation et sont disponibles [ici](https:
Nous téléchargeons le fichier de données en local (si celui-ci n'existe pas). Ceci afin de nous prémunir contre un éventuel problème de connexion à ce fichier. Nous téléchargeons le fichier de données en local (si celui-ci n'existe pas). Ceci afin de nous prémunir contre un éventuel problème de connexion à ce fichier.
```{r} ```{r}
data_url <- "https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/HistData/Wheat.csv" data_url <- "https://raw.githubusercontent.com/vincentarelbundock/
Rdatasets/master/csv/HistData/Wheat.csv"
dest_file <- "./wheat.csv" dest_file <- "./wheat.csv"
if(!file.exists(dest_file)) { if(!file.exists(dest_file)) {
download.file(url = data_url, destfile = dest_file, method = "auto") download.file(url = data_url, destfile = dest_file, method = "auto")
...@@ -51,7 +56,7 @@ playfair <- read_csv("wheat.csv", ...@@ -51,7 +56,7 @@ playfair <- read_csv("wheat.csv",
Les données obtenues sont de la forme : Les données obtenues sont de la forme :
```{r} ```{r}
head(playfair) %>% head(playfair) %>%
kable(format = "html", escape = FALSE, align ="c") %>% kable(align ="c") %>%
kable_styling(bootstrap_options = "striped", full_width = FALSE, position = "left") kable_styling(bootstrap_options = "striped", full_width = FALSE, position = "left")
``` ```
...@@ -85,7 +90,8 @@ playfair_area <- bind_rows(old = playfair, ...@@ -85,7 +90,8 @@ playfair_area <- bind_rows(old = playfair,
# Graphe de base : geom_ribbon # Graphe de base : geom_ribbon
p <- ggplot(playfair, aes(x = year)) + p <- ggplot(playfair, aes(x = year)) +
geom_ribbon(data = playfair_area, aes(ymin = 20, ymax = wheat), fill = "grey19", alpha = 0.9) geom_ribbon(data = playfair_area, aes(ymin = 20, ymax = wheat),
fill = "grey19", alpha = 0.9)
p p
``` ```
...@@ -115,7 +121,9 @@ p <- p + ...@@ -115,7 +121,9 @@ p <- p +
scale_y_continuous(limits = c(0, 100), scale_y_continuous(limits = c(0, 100),
breaks = seq(0, 100, by = 10), breaks = seq(0, 100, by = 10),
name = "", name = "",
sec.axis = sec_axis(~., name = "Price of the Quarter of Wheat in Shillings", sec.axis =
sec_axis(~.,
name = "Price of the Quarter of Wheat in Shillings",
breaks = seq(0, 100, by = 10))) breaks = seq(0, 100, by = 10)))
p p
``` ```
...@@ -136,11 +144,18 @@ p ...@@ -136,11 +144,18 @@ p
```{r warning=FALSE} ```{r warning=FALSE}
p <- p + p <- p +
annotate(geom = "label", x = 1650, y = 70, annotate(geom = "label", x = 1650, y = 70,
label = "CHART,\n Showing at One View\nThe Price of the Quater of Wheat,\n& Wages of Labour by the Week,\nfrom The Year 1565 to 1821,\nby William Playfair.", label = "CHART,
Showing at One View
The Price of the Quater of Wheat,
& Wages of Labour by the Week,
from The Year 1565 to 1821,
by William Playfair.",
fontface = "bold.italic", size = 3.5, family = "NewCenturySchoolbook", fontface = "bold.italic", size = 3.5, family = "NewCenturySchoolbook",
label.r = unit(3, "lines")) + label.r = unit(3, "lines")) +
annotate(geom = "text", x = c(1635, 1748), y = c(9, 18), label = "Weekly Wages of a Good Mechanic", annotate(geom = "text", x = c(1635, 1748), y = c(9, 18),
fontface = "italic", size = 2.7, angle = c(2, 10), family = "NewCenturySchoolbook") label = "Weekly Wages of a Good Mechanic",
fontface = "italic", size = 2.7, angle = c(2, 10),
family = "NewCenturySchoolbook")
p p
``` ```
...@@ -149,7 +164,7 @@ Pour la frise chronologique des rois et reines, nous allons utiliser les donnée ...@@ -149,7 +164,7 @@ Pour la frise chronologique des rois et reines, nous allons utiliser les donnée
# Fichier des rois et reines # Fichier des rois et reines
wheat_monarchs <- read_csv("wheat_monarchs.csv") wheat_monarchs <- read_csv("wheat_monarchs.csv")
wheat_monarchs %>% wheat_monarchs %>%
kable(format = "html", escape = FALSE, align ="c") %>% kable(align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = FALSE, position = "left") kable_styling(bootstrap_options = "striped", full_width = FALSE, position = "left")
``` ```
...@@ -157,14 +172,26 @@ wheat_monarchs %>% ...@@ -157,14 +172,26 @@ wheat_monarchs %>%
```{r warning=FALSE} ```{r warning=FALSE}
p <- p + p <- p +
# rois/reines sur la barre supérieure # rois/reines sur la barre supérieure
geom_rect(data = wheat_monarchs %>% filter(row_number() %% 2 == 1, is.na(commonwealth)), aes(xmin = start, xmax = end, ymin = 97, ymax = 98), inherit.aes = FALSE) + geom_rect(data = wheat_monarchs %>% filter(row_number() %% 2 == 1, is.na(commonwealth)),
geom_text(data = wheat_monarchs %>% filter(row_number() %% 2 == 1, is.na(commonwealth)), aes(x = start + (end -start) / 2, y = 96, label = name), size = 2, family = "NewCenturySchoolbook", fontface = "italic") + aes(xmin = start, xmax = end, ymin = 97, ymax = 98),
inherit.aes = FALSE) +
geom_text(data = wheat_monarchs %>% filter(row_number() %% 2 == 1, is.na(commonwealth)),
aes(x = start + (end -start) / 2, y = 96, label = name),
size = 2, family = "NewCenturySchoolbook", fontface = "italic") +
# rois/reines sur la barre inférieure # rois/reines sur la barre inférieure
geom_rect(data = wheat_monarchs %>% filter(row_number() %% 2 == 0, is.na(commonwealth)), aes(xmin = start, xmax = end, ymin = 96, ymax = 97), inherit.aes = FALSE) + geom_rect(data = wheat_monarchs %>% filter(row_number() %% 2 == 0, is.na(commonwealth)),
geom_text(data = wheat_monarchs %>% filter(row_number() %% 2 == 0, is.na(commonwealth)), aes(x = start + (end -start) / 2, y = 95, label = name), size = 2, family = "NewCenturySchoolbook", fontface = "italic") + aes(xmin = start, xmax = end, ymin = 96, ymax = 97),
inherit.aes = FALSE) +
geom_text(data = wheat_monarchs %>% filter(row_number() %% 2 == 0, is.na(commonwealth)),
aes(x = start + (end -start) / 2, y = 95, label = name),
size = 2, family = "NewCenturySchoolbook", fontface = "italic") +
# cas particulier de Cromwell # cas particulier de Cromwell
geom_rect(data = wheat_monarchs %>% filter(commonwealth), aes(xmin = start, xmax = end, ymin = 97, ymax = 98), inherit.aes = FALSE, fill = "white", color = "black") + geom_rect(data = wheat_monarchs %>% filter(commonwealth),
geom_text(data = wheat_monarchs %>% filter(commonwealth), aes(x = start + (end -start) / 2, y = 96, label = name), size = 2, family = "NewCenturySchoolbook", fontface = "italic") aes(xmin = start, xmax = end, ymin = 97, ymax = 98),
inherit.aes = FALSE, fill = "white", color = "black") +
geom_text(data = wheat_monarchs %>% filter(commonwealth),
aes(x = start + (end -start) / 2, y = 96, label = name),
size = 2, family = "NewCenturySchoolbook", fontface = "italic")
p p
``` ```
...@@ -174,16 +201,20 @@ p ...@@ -174,16 +201,20 @@ p
p <- p + p <- p +
theme(plot.margin = unit(c(1.2,0.8,0.5,0), units = "cm")) + theme(plot.margin = unit(c(1.2,0.8,0.5,0), units = "cm")) +
annotation_custom(grob = textGrob(label = "shillings", annotation_custom(grob = textGrob(label = "shillings",
gp = gpar(fontsize = 8, fontface = "italic", fontfamily = "NewCenturySchoolbook")), gp = gpar(fontsize = 8, fontface = "italic",
fontfamily = "NewCenturySchoolbook")),
xmin = 1844, xmax = 1844, ymin = 100, ymax = 100) + xmin = 1844, xmax = 1844, ymin = 100, ymax = 100) +
annotation_custom(grob = textGrob(label = "shillings", annotation_custom(grob = textGrob(label = "shillings",
gp = gpar(fontsize = 8, fontface = "italic", fontfamily = "NewCenturySchoolbook")), gp = gpar(fontsize = 8, fontface = "italic",
fontfamily = "NewCenturySchoolbook")),
xmin = 1841, xmax = 1841, ymin = 0, ymax = 0) + xmin = 1841, xmax = 1841, ymin = 0, ymax = 0) +
annotation_custom(grob = textGrob(label = "5 Years each division", annotation_custom(grob = textGrob(label = "5 Years each division",
gp = gpar(fontsize = 8, fontface = "italic", fontfamily = "NewCenturySchoolbook")), gp = gpar(fontsize = 8, fontface = "italic",
fontfamily = "NewCenturySchoolbook")),
xmin = 1650, xmax = 1650, ymin = -5, ymax = -5) + xmin = 1650, xmax = 1650, ymin = -5, ymax = -5) +
annotation_custom(grob = textGrob(label = "5 Years each division", annotation_custom(grob = textGrob(label = "5 Years each division",
gp = gpar(fontsize = 8, fontface = "italic", fontfamily = "NewCenturySchoolbook")), gp = gpar(fontsize = 8, fontface = "italic",
fontfamily = "NewCenturySchoolbook")),
xmin = 1785, xmax = 1785, ymin = -5, ymax = -5) xmin = 1785, xmax = 1785, ymin = -5, ymax = -5)
p p
...@@ -193,31 +224,41 @@ p ...@@ -193,31 +224,41 @@ p
```{r warning=FALSE} ```{r warning=FALSE}
p <- p + p <- p +
annotation_custom(grob = textGrob(label = "16th Century", annotation_custom(grob = textGrob(label = "16th Century",
gp = gpar(fontsize = 8, fontfamily = "NewCenturySchoolbook")), gp = gpar(fontsize = 8,
fontfamily = "NewCenturySchoolbook")),
xmin = 1577, xmax = 1577, ymin = 102.5, ymax = 102.5) + xmin = 1577, xmax = 1577, ymin = 102.5, ymax = 102.5) +
annotation_custom(grob = textGrob(label = "17th Century", annotation_custom(grob = textGrob(label = "17th Century",
gp = gpar(fontsize = 8, fontfamily = "NewCenturySchoolbook")), gp = gpar(fontsize = 8,
fontfamily = "NewCenturySchoolbook")),
xmin = 1650, xmax = 1650, ymin = 102.5, ymax = 102.5) + xmin = 1650, xmax = 1650, ymin = 102.5, ymax = 102.5) +
annotation_custom(grob = textGrob(label = "18th Century", annotation_custom(grob = textGrob(label = "18th Century",
gp = gpar(fontsize = 8, fontfamily = "NewCenturySchoolbook")), gp = gpar(fontsize = 8,
fontfamily = "NewCenturySchoolbook")),
xmin = 1750, xmax = 1750, ymin = 102.5, ymax = 102.5) + xmin = 1750, xmax = 1750, ymin = 102.5, ymax = 102.5) +
annotation_custom(grob = textGrob(label = "19th Century", annotation_custom(grob = textGrob(label = "19th Century",
gp = gpar(fontsize = 8, fontfamily = "NewCenturySchoolbook")), gp = gpar(fontsize = 8,
fontfamily = "NewCenturySchoolbook")),
xmin = 1820, xmax = 1820, ymin = 102.5, ymax = 102.5) + xmin = 1820, xmax = 1820, ymin = 102.5, ymax = 102.5) +
annotation_custom(grob = curveGrob(x1 = 0, y1 = 1, x2 = 1, y2 = 0, curvature = -0.12, square = FALSE, ncp = 20, annotation_custom(grob = curveGrob(x1 = 0, y1 = 1, x2 = 1, y2 = 0, curvature = -0.12,
square = FALSE, ncp = 20,
gp = gpar(col = "black", lwd = 3)), gp = gpar(col = "black", lwd = 3)),
xmin = 1565, xmax = 1600, ymin = 105, ymax = 100) + xmin = 1565, xmax = 1600, ymin = 105, ymax = 100) +
annotation_custom(grob = curveGrob(x1 = 0, y1 = 0, x2 = 1, y2 = 1, curvature = -0.15, square = FALSE, ncp = 20, annotation_custom(grob = curveGrob(x1 = 0, y1 = 0, x2 = 1, y2 = 1, curvature = -0.15,
square = FALSE, ncp = 20,
gp = gpar(col = "black", lwd = 3)), gp = gpar(col = "black", lwd = 3)),
xmin = 1600, xmax = 1700, ymin = 100, ymax = 100) + xmin = 1600, xmax = 1700, ymin = 100, ymax = 100) +
annotation_custom(grob = curveGrob(x1 = 0, y1 = 0, x2 = 1, y2 = 1, curvature = -0.15, square = FALSE, ncp = 20, annotation_custom(grob = curveGrob(x1 = 0, y1 = 0, x2 = 1, y2 = 1, curvature = -0.15,
square = FALSE, ncp = 20,
gp = gpar(col = "black", lwd = 3)), gp = gpar(col = "black", lwd = 3)),
xmin = 1700, xmax = 1800, ymin = 100, ymax = 100) + xmin = 1700, xmax = 1800, ymin = 100, ymax = 100) +
annotation_custom(grob = curveGrob(x1 = 0, y1 = 0, x2 = 1, y2 = 1, curvature = -0.12, square = FALSE, ncp = 20, annotation_custom(grob = curveGrob(x1 = 0, y1 = 0, x2 = 1, y2 = 1, curvature = -0.12,
square = FALSE, ncp = 20,
gp = gpar(col = "black", lwd = 3)), gp = gpar(col = "black", lwd = 3)),
xmin = 1800, xmax = 1830, ymin = 100, ymax = 105) + xmin = 1800, xmax = 1830, ymin = 100, ymax = 105) +
annotation_custom(grob = textGrob(label = "N°1", annotation_custom(grob = textGrob(label = "N°1",
gp = gpar(fontsize = 11, fontfamily = "NewCenturySchoolbook", fontface = "bold")), gp = gpar(fontsize = 11,
fontfamily = "NewCenturySchoolbook",
fontface = "bold")),
xmin = 1700, xmax = 1700, ymin = 104, ymax = 104) xmin = 1700, xmax = 1700, ymin = 104, ymax = 104)
p p
...@@ -295,7 +336,7 @@ playfair %>% ...@@ -295,7 +336,7 @@ playfair %>%
geom_step(color = "red", alpha = 0.6, size = 0.8) + geom_step(color = "red", alpha = 0.6, size = 0.8) +
geom_smooth(se = FALSE, lwd = 0.5, lty = 2, span = 0.4) + geom_smooth(se = FALSE, lwd = 0.5, lty = 2, span = 0.4) +
labs(x = "", y = "Wheat Quantity (Quarter of a Bushel)", labs(x = "", y = "Wheat Quantity (Quarter of a Bushel)",
title = "How many Wheat can I buy with my Weekly Wage ?") + title = "How much Wheat can I buy with my Weekly Wage ?") +
theme_light() theme_light()
``` ```
...@@ -334,9 +375,9 @@ playfair %>% ...@@ -334,9 +375,9 @@ playfair %>%
ggplot(aes(x = wages, y = purchase_power)) + ggplot(aes(x = wages, y = purchase_power)) +
geom_point() + geom_point() +
geom_smooth(se = FALSE, lwd = 0.5, lty = 2) + geom_smooth(se = FALSE, lwd = 0.5, lty = 2) +
labs(x = "Weekly Wage (in shillinigs)", labs(x = "Weekly Wage (in shillings)",
y = "Purchasing Power", y = "Purchasing Power",
title = "Purchsing Power / Weekly Wage relationship") + title = "Purchasing Power / Weekly Wage relationship") +
theme_light() theme_light()
``` ```
......
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