Exercises:

#Load the Arbuthnot baptism data
source("more/arbuthnot.R")
  1. What command would you use to extract just the counts of girls baptized? Try it!
#Selects only the girl column
arbuthnot$girls
##  [1] 4683 4457 4102 4590 4839 4820 4928 4605 4457 4952 4784 5332 5200 4910
## [15] 4617 3997 3919 3395 3536 3181 2746 2722 2840 2908 2959 3179 3349 3382
## [29] 3289 3013 2781 3247 4107 4803 4881 5681 4858 4319 5322 5560 5829 5719
## [43] 6061 6120 5822 5738 5717 5847 6203 6033 6041 6299 6533 6744 7158 7127
## [57] 7246 7119 7214 7101 7167 7302 7392 7316 7483 6647 6713 7229 7767 7626
## [71] 7452 7061 7514 7656 7683 5738 7779 7417 7687 7623 7380 7288
  1. Is there an apparent trend in the number of girls baptized over the years?
    How would you describe it?
plot(x = arbuthnot$year, y = arbuthnot$girls, type = "l")

There appears to be a positive correlation between year and the number of girls baptized each year. In other words, as the year increases, the number of girls baptized tends to increase as well. I would describe the relationship as a positive, somewhat linear relationship between the year and the number of girls baptized each year.

  1. Now, make a plot of the proportion of boys over time. What do you see? Tip: If you use the up and down arrow keys, you can scroll through your previous commands, your so-called command history. You can also access it by clicking on the history tab in the upper right panel. This will save you a lot of typing in the future.
plot(x = arbuthnot$year, y = arbuthnot$boys / (arbuthnot$boys + arbuthnot$girls))

There does not appear to be any relationship between the year and the proportion of boys baptized. The points are scattered pretty randomly across all years, however all points are located on a narrow band between 0.5 and 0.54. It would appear that the proportion of boys baptized does not deviate significantly from about 0.52 each year.


On Your Own

source("more/present.R")

The data are stored in a data frame called present.

What years are included in this data set? What are the dimensions of the data frame and what are the variable or column names?

#Years:

present$year
##  [1] 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953
## [15] 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967
## [29] 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981
## [43] 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995
## [57] 1996 1997 1998 1999 2000 2001 2002
#Dimensions:

dim(present)
## [1] 63  3
#Names:
names(present)
## [1] "year"  "boys"  "girls"

How do these counts compare to Arbuthnot’s? Are they on a similar scale?

c(ArbuthnotBoys = floor(mean(arbuthnot$boys)), 
  PresentBoys = floor(mean(present$boys)),
  ArbuthnotGirls = floor(mean(arbuthnot$girls)),
  PresentGirls = floor(mean(present$girls)))
##  ArbuthnotBoys    PresentBoys ArbuthnotGirls   PresentGirls 
##           5907        1885599           5534        1793915

The counts in the presents dataframe are significantly larger than the counts in the arbuthnot dataframe.

Make a plot that displays the boy-to-girl ratio for every year in the data set. What do you see? Does Arbuthnot’s observation about boys being born in greater proportion than girls hold up in the U.S.? Include the plot in your response.

plot(x = present$year, y = present$boys/present$girls, main = "Boy-to-Girl Ratio per Year", xlab = "Year", ylab = "Boy-to-Girl Ratio")

According to the plot, ratio of boys to girls born each year appears to fluctuate between 1.04 and 1.06 each year. If girls were being born in greater proportion than boys, the ratio would need to be consistently less than 1 each year. Since all of the ratios are greater than 1.04, Arbuthnot’s observation of boys being born in greater proportion than girls seems to be correct.

In what year did we see the most total number of births in the U.S.?

present$bgsum = present$boys + present$girls

present[which.max(present$bgsum),]
##    year    boys   girls   bgsum
## 22 1961 2186274 2082052 4268326

1961 had the most total number of births in the United States.