library(tidyverse)
library(openintro)
library(tidyverse)
library(openintro)

Exercise 1

arbuthnot$girls
##  [1] 4683 4457 4102 4590 4839 4820 4928 4605 4457 4952 4784 5332 5200 4910 4617
## [16] 3997 3919 3395 3536 3181 2746 2722 2840 2908 2959 3179 3349 3382 3289 3013
## [31] 2781 3247 4107 4803 4881 5681 4858 4319 5322 5560 5829 5719 6061 6120 5822
## [46] 5738 5717 5847 6203 6033 6041 6299 6533 6744 7158 7127 7246 7119 7214 7101
## [61] 7167 7302 7392 7316 7483 6647 6713 7229 7767 7626 7452 7061 7514 7656 7683
## [76] 5738 7779 7417 7687 7623 7380 7288

Exercise 2

Exploring Dr. Arbuthnot’s Baptism Records.

data('arbuthnot', package = 'openintro')

Viewing the entire data frame:

Viewing only the dimensions of the data frame and the variables contained the data frame:

glimpse(arbuthnot)
## Rows: 82
## Columns: 3
## $ year  <int> 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639…
## $ boys  <int> 5218, 4858, 4422, 4994, 5158, 5035, 5106, 4917, 4703, 5359, 5366…
## $ girls <int> 4683, 4457, 4102, 4590, 4839, 4820, 4928, 4605, 4457, 4952, 4784…
head(arbuthnot)
## # A tibble: 6 × 3
##    year  boys girls
##   <int> <int> <int>
## 1  1629  5218  4683
## 2  1630  4858  4457
## 3  1631  4422  4102
## 4  1632  4994  4590
## 5  1633  5158  4839
## 6  1634  5035  4820

Examining exclusively the boys column:

arbuthnot$boys
##  [1] 5218 4858 4422 4994 5158 5035 5106 4917 4703 5359 5366 5518 5470 5460 4793
## [16] 4107 4047 3768 3796 3363 3079 2890 3231 3220 3196 3441 3655 3668 3396 3157
## [31] 3209 3724 4748 5216 5411 6041 5114 4678 5616 6073 6506 6278 6449 6443 6073
## [46] 6113 6058 6552 6423 6568 6247 6548 6822 6909 7577 7575 7484 7575 7737 7487
## [61] 7604 7909 7662 7602 7676 6985 7263 7632 8062 8426 7911 7578 8102 8031 7765
## [76] 6113 8366 7952 8379 8239 7840 7640

Exploring only the girls:

arbuthnot$girls
##  [1] 4683 4457 4102 4590 4839 4820 4928 4605 4457 4952 4784 5332 5200 4910 4617
## [16] 3997 3919 3395 3536 3181 2746 2722 2840 2908 2959 3179 3349 3382 3289 3013
## [31] 2781 3247 4107 4803 4881 5681 4858 4319 5322 5560 5829 5719 6061 6120 5822
## [46] 5738 5717 5847 6203 6033 6041 6299 6533 6744 7158 7127 7246 7119 7214 7101
## [61] 7167 7302 7392 7316 7483 6647 6713 7229 7767 7626 7452 7061 7514 7656 7683
## [76] 5738 7779 7417 7687 7623 7380 7288

Descriptive statistics:

summary(arbuthnot)
##       year           boys          girls     
##  Min.   :1629   Min.   :2890   Min.   :2722  
##  1st Qu.:1649   1st Qu.:4759   1st Qu.:4457  
##  Median :1670   Median :6073   Median :5718  
##  Mean   :1670   Mean   :5907   Mean   :5535  
##  3rd Qu.:1690   3rd Qu.:7576   3rd Qu.:7150  
##  Max.   :1710   Max.   :8426   Max.   :7779

Exercise 3

Data Visualization.

?ggplot

Historical trend in boys baptism

ggplot(data = arbuthnot, aes(x=year, y=boys)) +
geom_point()

ggplot(data = arbuthnot, aes(x = year, y = boys))+
  
geom_line()

ggplot(data = arbuthnot, aes(x=year, y= girls)) +
geom_line()

ggplot(data = arbuthnot, aes(x =year, y =girls))+
geom_point()

Interpreting the findings: Both graphics reveal a continuous increase in the numbers of children who receive baptism over the years. The observed trends and patterns are similar for both boys and girls for the period covered by the data frame.

Calculating the ratio of newborn boys over newborn girls in 1629:

5218/4683
## [1] 1.114243

Finding the ratio of newborns that are boys for each year of the data set:

arbuthnot <-arbuthnot %>% 
  mutate (boy_to_girl_ratio = boys/girls)
print(arbuthnot)
## # A tibble: 82 × 4
##     year  boys girls boy_to_girl_ratio
##    <int> <int> <int>             <dbl>
##  1  1629  5218  4683              1.11
##  2  1630  4858  4457              1.09
##  3  1631  4422  4102              1.08
##  4  1632  4994  4590              1.09
##  5  1633  5158  4839              1.07
##  6  1634  5035  4820              1.04
##  7  1635  5106  4928              1.04
##  8  1636  4917  4605              1.07
##  9  1637  4703  4457              1.06
## 10  1638  5359  4952              1.08
## # ℹ 72 more rows

Finding the proportion of the newborns that are boys for all years simultaneously

arbuthnot <-arbuthnot %>% 
mutate ( boy_ratio = boys/arbuthnot$boys +arbuthnot$girls)
print(arbuthnot)
## # A tibble: 82 × 5
##     year  boys girls boy_to_girl_ratio boy_ratio
##    <int> <int> <int>             <dbl>     <dbl>
##  1  1629  5218  4683              1.11      4684
##  2  1630  4858  4457              1.09      4458
##  3  1631  4422  4102              1.08      4103
##  4  1632  4994  4590              1.09      4591
##  5  1633  5158  4839              1.07      4840
##  6  1634  5035  4820              1.04      4821
##  7  1635  5106  4928              1.04      4929
##  8  1636  4917  4605              1.07      4606
##  9  1637  4703  4457              1.06      4458
## 10  1638  5359  4952              1.08      4953
## # ℹ 72 more rows

Plot of the proportion of boys born over time:

library(ggplot2)

ggplot(data = arbuthnot, aes(x = year , y =boy_to_girl_ratio ))+
  
geom_point()

ggplot(data = arbuthnot, aes(x = year , y =boy_to_girl_ratio ))+
  
geom_line()

Interpreting the findings: One notices the absence of the linear, upward, and mostly one directional patterns observed while examining the trends in baptism over years. Linearity has been replaced by a zigzag line when when exploring the trends via ratio/proportion.

Finding whether the number of births of boys outnumber that of girls in each year:

arbuthnot <- arbuthnot %>% 
mutate(more_boys = boys > girls)
glimpse(arbuthnot)
## Rows: 82
## Columns: 6
## $ year              <int> 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637…
## $ boys              <int> 5218, 4858, 4422, 4994, 5158, 5035, 5106, 4917, 4703…
## $ girls             <int> 4683, 4457, 4102, 4590, 4839, 4820, 4928, 4605, 4457…
## $ boy_to_girl_ratio <dbl> 1.114243, 1.089971, 1.078011, 1.088017, 1.065923, 1.…
## $ boy_ratio         <dbl> 4684, 4458, 4103, 4591, 4840, 4821, 4929, 4606, 4458…
## $ more_boys         <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE…

Finding the max and the minimum amount of boys born in a year within the arbuthnot data frame:

arbuthnot %>% 
summarise(min = min(boys), max = max(boys))
## # A tibble: 1 × 2
##     min   max
##   <int> <int>
## 1  2890  8426

Exercise 4

Loading and exploring the data frame: Finding the dimension and variables using the glimpse function:

data('present', package = "openintro")
glimpse(present)
## Rows: 63
## Columns: 3
## $ year  <dbl> 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950…
## $ boys  <dbl> 1211684, 1289734, 1444365, 1508959, 1435301, 1404587, 1691220, 1…
## $ girls <dbl> 1148715, 1223693, 1364631, 1427901, 1359499, 1330869, 1597452, 1…

Finding the variables name using the head() function

head(present)
## # A tibble: 6 × 3
##    year    boys   girls
##   <dbl>   <dbl>   <dbl>
## 1  1940 1211684 1148715
## 2  1941 1289734 1223693
## 3  1942 1444365 1364631
## 4  1943 1508959 1427901
## 5  1944 1435301 1359499
## 6  1945 1404587 1330869

Descriptive statistics:

summary(present)
##       year           boys             girls        
##  Min.   :1940   Min.   :1211684   Min.   :1148715  
##  1st Qu.:1956   1st Qu.:1799857   1st Qu.:1711404  
##  Median :1971   Median :1924868   Median :1831679  
##  Mean   :1971   Mean   :1885600   Mean   :1793915  
##  3rd Qu.:1986   3rd Qu.:2058524   3rd Qu.:1965538  
##  Max.   :2002   Max.   :2186274   Max.   :2082052

Exercise 5

Finding the max and the minimum amount of boys born in a year with present data frame:

present %>% 
summarise(min = min(boys), max = max(boys))
## # A tibble: 1 × 2
##       min     max
##     <dbl>   <dbl>
## 1 1211684 2186274

The counts in present (above) data frame are of much bigger magnitude in scope when compared with the nab data set (below)

## # A tibble: 1 × 2
##     min   max
##   <int> <int>
## 1  2890  8426

Proportion of newborns that are boys:

present <- present %>% 
mutate(boy_ratio = boys/present$boys|present$girls)
glimpse(present)
## Rows: 63
## Columns: 4
## $ year      <dbl> 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, …
## $ boys      <dbl> 1211684, 1289734, 1444365, 1508959, 1435301, 1404587, 169122…
## $ girls     <dbl> 1148715, 1223693, 1364631, 1427901, 1359499, 1330869, 159745…
## $ boy_ratio <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, …
present <-present %>% 
  mutate (boy_to_girl_ratio = boys/girls)
print(present)
## # A tibble: 63 × 5
##     year    boys   girls boy_ratio boy_to_girl_ratio
##    <dbl>   <dbl>   <dbl> <lgl>                 <dbl>
##  1  1940 1211684 1148715 TRUE                   1.05
##  2  1941 1289734 1223693 TRUE                   1.05
##  3  1942 1444365 1364631 TRUE                   1.06
##  4  1943 1508959 1427901 TRUE                   1.06
##  5  1944 1435301 1359499 TRUE                   1.06
##  6  1945 1404587 1330869 TRUE                   1.06
##  7  1946 1691220 1597452 TRUE                   1.06
##  8  1947 1899876 1800064 TRUE                   1.06
##  9  1948 1813852 1721216 TRUE                   1.05
## 10  1949 1826352 1733177 TRUE                   1.05
## # ℹ 53 more rows

Exercise 6

Graphics/data visualization.

ggplot(data = present, aes(x =year, y =boys))+
geom_point()

ggplot(data = present, aes(x =year, y =boys))+
geom_line()

ggplot(data = present, aes(x =year, y =girls))+
geom_line()

ggplot(data = present, aes(x = year , y =boy_to_girl_ratio ))+
  
geom_point()

ggplot(data = present, aes(x = year , y =boy_to_girl_ratio ))+
  
geom_line()

Plots showing the proportion of boys born over time in the US from 1940 to 2002:

ggplot(data = present,aes(x= year, y= boy_to_girl_ratio )) +
  geom_point()

ggplot(data = present,aes(x= year, y= boy_to_girl_ratio )) +
  geom_line()

Interpreting the graphics:

The present data frame reveals a downside trend in newborns in the U.S. during the second half of the 20th century (1940 -2002). The descending curve of the plot is also in sharp opposition with the ascending curve observed in London during the 18th century as illustrated by the arbuthnot data frame.

Exercise 7

Do newborn boys outnumbers girls per year in present?

summary(present)
##       year           boys             girls         boy_ratio     
##  Min.   :1940   Min.   :1211684   Min.   :1148715   Mode:logical  
##  1st Qu.:1956   1st Qu.:1799857   1st Qu.:1711404   TRUE:63       
##  Median :1971   Median :1924868   Median :1831679                 
##  Mean   :1971   Mean   :1885600   Mean   :1793915                 
##  3rd Qu.:1986   3rd Qu.:2058524   3rd Qu.:1965538                 
##  Max.   :2002   Max.   :2186274   Max.   :2082052                 
##  boy_to_girl_ratio
##  Min.   :1.046    
##  1st Qu.:1.050    
##  Median :1.051    
##  Mean   :1.051    
##  3rd Qu.:1.053    
##  Max.   :1.059

Year with the highest total number of births: was 2002

present %>% 
  arrange(desc(total))
## # A tibble: 63 × 5
##     year    boys   girls boy_ratio boy_to_girl_ratio
##    <dbl>   <dbl>   <dbl> <lgl>                 <dbl>
##  1  2002 2057979 1963747 TRUE                   1.05
##  2  2001 2057922 1968011 TRUE                   1.05
##  3  2000 2076969 1981845 TRUE                   1.05
##  4  1999 2026854 1932563 TRUE                   1.05
##  5  1998 2016205 1925348 TRUE                   1.05
##  6  1997 1985596 1895298 TRUE                   1.05
##  7  1996 1990480 1901014 TRUE                   1.05
##  8  1995 1996355 1903234 TRUE                   1.05
##  9  1994 2022589 1930178 TRUE                   1.05
## 10  1993 2048861 1951379 TRUE                   1.05
## # ℹ 53 more rows
LS0tCnRpdGxlOiAiTGFiIDE6IEludHJvIHRvIFIiCmF1dGhvcjogIkhlbGVpbmUgRm91ZGEiCmRhdGU6ICJgciBTeXMuRGF0ZSgpYCIKb3V0cHV0OiBvcGVuaW50cm86OmxhYl9yZXBvcnQKLS0tCgpgYGB7ciBsb2FkLXBhY2thZ2VzLCBtZXNzYWdlPUZBTFNFfQpsaWJyYXJ5KHRpZHl2ZXJzZSkKbGlicmFyeShvcGVuaW50cm8pCmxpYnJhcnkodGlkeXZlcnNlKQpsaWJyYXJ5KG9wZW5pbnRybykKCmBgYAoKIyMjIEV4ZXJjaXNlIDEKCmBgYHtyIHZpZXctZ2lybHMtY291bnRzfQphcmJ1dGhub3QkZ2lybHMKYGBgCgoKIyMjIEV4ZXJjaXNlIDIKCkV4cGxvcmluZyBEci4gQXJidXRob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