library(ggplot2)
data('arbuthnot', package='openintro')
data('present', package='openintro')
PresentBirthData = data.frame(present)
PresentBirthData[,3]
## [1] 1148715 1223693 1364631 1427901 1359499 1330869 1597452 1800064 1721216
## [10] 1733177 1730594 1827830 1875724 1900322 1958294 1973576 2029502 2074824
## [19] 2051266 2071158 2078142 2082052 2034896 1996388 1967328 1833304 1760412
## [28] 1717571 1705238 1753634 1816008 1733060 1588484 1528639 1537844 1531063
## [37] 1543352 1620716 1623885 1703131 1759642 1768966 1794861 1773380 1789651
## [46] 1832578 1831679 1858241 1907086 1971468 2028717 2009389 1982917 1951379
## [55] 1930178 1903234 1901014 1895298 1925348 1932563 1981845 1968011 1963747
ggplot(PresentBirthData, aes(x=year)) + geom_line(aes(y=girls), color ="darkred")
ggplot(PresentBirthData, aes(x=year)) + geom_line(aes(y=boys), color ="green")
## I see that it matches the proportion of girls almost exactly.
range(PresentBirthData$year)
## [1] 1940 2002
dim(PresentBirthData)
## [1] 63 3
names(PresentBirthData)
## [1] "year" "boys" "girls"
ggplot(arbuthnot, aes(x=year)) + geom_line(aes(y=boys), color ="darkred")
## Yes it seems that a higher proportion of boys are being born over
time.
for (i in 1:nrow(PresentBirthData)) {
PresentBirthData$total[i] <- PresentBirthData$boys[i] + PresentBirthData$girls[i]
}
PresentBirthData[which.max(PresentBirthData$total),]
## year boys girls total
## 22 1961 2186274 2082052 4268326