In this analysis, we explore the Swiss fertility data collected in 1888. The dataset contains information on fertility rates and various socioeconomic indicators for different regions or cantons within Switzerland during that period.
Swiss Data Overview
Inspecting the structure and contents of the Swiss data.
Generate Summary Table for the Swiss Data
summary (swiss)
Fertility Agriculture Examination Education
Min. :35.00 Min. : 1.20 Min. : 3.00 Min. : 1.00
1st Qu.:64.70 1st Qu.:35.90 1st Qu.:12.00 1st Qu.: 6.00
Median :70.40 Median :54.10 Median :16.00 Median : 8.00
Mean :70.14 Mean :50.66 Mean :16.49 Mean :10.98
3rd Qu.:78.45 3rd Qu.:67.65 3rd Qu.:22.00 3rd Qu.:12.00
Max. :92.50 Max. :89.70 Max. :37.00 Max. :53.00
Catholic Infant.Mortality
Min. : 2.150 Min. :10.80
1st Qu.: 5.195 1st Qu.:18.15
Median : 15.140 Median :20.00
Mean : 41.144 Mean :19.94
3rd Qu.: 93.125 3rd Qu.:21.70
Max. :100.000 Max. :26.60
library(gt) # loads gt, do once in your sessiongt(as.data.frame.matrix(summary(swiss)))
Fertility
Agriculture
Examination
Education
Catholic
Infant.Mortality
Min. :35.00
Min. : 1.20
Min. : 3.00
Min. : 1.00
Min. : 2.150
Min. :10.80
1st Qu.:64.70
1st Qu.:35.90
1st Qu.:12.00
1st Qu.: 6.00
1st Qu.: 5.195
1st Qu.:18.15
Median :70.40
Median :54.10
Median :16.00
Median : 8.00
Median : 15.140
Median :20.00
Mean :70.14
Mean :50.66
Mean :16.49
Mean :10.98
Mean : 41.144
Mean :19.94
3rd Qu.:78.45
3rd Qu.:67.65
3rd Qu.:22.00
3rd Qu.:12.00
3rd Qu.: 93.125
3rd Qu.:21.70
Max. :92.50
Max. :89.70
Max. :37.00
Max. :53.00
Max. :100.000
Max. :26.60
Table Showing Counties and Variables
knitr::kable(swiss[1:5, ], )
Fertility
Agriculture
Examination
Education
Catholic
Infant.Mortality
Courtelary
80.2
17.0
15
12
9.96
22.2
Delemont
83.1
45.1
6
9
84.84
22.2
Franches-Mnt
92.5
39.7
5
5
93.40
20.2
Moutier
85.8
36.5
12
7
33.77
20.3
Neuveville
76.9
43.5
17
15
5.16
20.6
Plot Swiss Data Comparing Fertility with Education
plot (Infant.Mortality~Fertility, data = swiss,xlab ="Fertility",ylab ="Infant.Mortality",main ="Infant Mortality and Fertility",pch =16) # Point shape
Bar Graph of education Levels
barplot(table(swiss$Education), main ="Bar Graph of Education Levels",xlab ="Education Level",ylab ="Frequency",col ="skyblue",ylim =c(0, max(table(swiss$Education)) +2) # Adjust ylim to ensure all bars are visible)