forked from ThinkR-open/prenoms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
72 lines (59 loc) · 2.01 KB
/
README.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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
<!-- badges: start -->
[![R-CMD-check](https://github.com/ThinkR-open/prenoms/workflows/R-CMD-check/badge.svg)](https://github.com/ThinkR-open/prenoms/actions)
<!-- badges: end -->
# prenoms
First names given to babies in metropolitan France between 1900 and 2019.
```
devtools::install_github( "ThinkR-open/prenoms" )
library("prenoms")
```
For example, names from current [ThinkR](https://thinkr.fr) staff [Colin](https://github.com/colinfay),
[Diane](https://github.com/DianeBeldame), [Sébastien](https://github.com/statnmap),
[Cervan](https://github.com/Cervangirard) &
[Vincent](https://github.com/VincentGuyader) through time.
```{r warning=FALSE,message=FALSE}
library("ggplot2")
library("dplyr")
library("tidyr")
library(prenoms)
data(prenoms)
thinkrs <- prenoms %>%
filter(
name == "Diane" & sex == "F" |
name == "Sébastien" & sex == "M" |
name == "Colin" & sex == "M" |
name == "Cervan" & sex == "M" |
name == "Margot" & sex == "F" |
name == "Vincent" & sex == "M"
) %>%
complete(name = c("Diane","Sébastien","Colin","Cervan","Margot","Vincent"),year=1900:2019,fill = list(n=0,prop=0)) %>%
group_by(name, year, sex) %>%
summarise( n = sum(n) ) %>%
arrange( year ) %>%
mutate(
sex = case_when(
is.na(sex) & name == "Cervan" ~ "M",
is.na(sex) & name == "Colin" ~ "M",
is.na(sex) & name == "Diane" ~ "F",
is.na(sex) & name == "Margot" ~ "F",
is.na(sex) & name == "Sébastien" ~ "M",
is.na(sex) & name == "Vincent" ~ "M",
TRUE ~ sex
)
)
ggplot( thinkrs, aes(x = year, y = n, color = name) ) +
geom_line() +
scale_x_continuous( breaks = seq(1900, 2020, by = 10) )+theme_bw()
```