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

There was a steady decline of the number of girls born between the year of 1640 and 1650. However, there seems to be an increasig number of girl births from the year 1660 unwards.

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

Exercise 3

There seem to be consistent number or proportion of boys over the years. By observing the numerical proportion, it seems to be approximately higher than the proportion of girls born over the years.

arbuthnot <- arbuthnot %>% mutate(total = boys + girls)
arbuthnot
ggplot(data = arbuthnot, aes(x = year, y= total)) + geom_line()

arbuthnot <- arbuthnot %>% mutate(boy_ratio = boys / total)
arbuthnot
ggplot(data = arbuthnot, aes(x = year, y= boy_ratio)) + geom_line()

Exercise 4

The data set includes data from the year 1940 to 2002. The data frame contains 63 rows and 3 columns.The columns are named year, boys and girls.

View(present)
dim(present)
## [1] 63  3

Exercise 5

The data frame arbuthnot has a larger magnitude than the data frame present. Arbuthnot has 83 rows whiles present has 63 rows. However, they both have the same number of colums and measures the same concept or item.

all.equal(arbuthnot , present)
## [1] "Attributes: < Component \"row.names\": Numeric: lengths (82, 63) differ >"
## [2] "Length mismatch: comparison on first 3 components"                        
## [3] "Component \"year\": Numeric: lengths (82, 63) differ"                     
## [4] "Component \"boys\": Numeric: lengths (82, 63) differ"                     
## [5] "Component \"girls\": Numeric: lengths (82, 63) differ"

Exercise 6

The proportion of boys seems to be higher in the earlier years of the data frame. This pattern changes over time steadily and closer to the end of the dataframe, the proportion is fairly low.

Exercise 7

The year 1961 saw the most total number of birth in the US.