To initialize this lab, we first set the working directory, and source the arbuthnot data set.
setwd("C:/Users/Robert/Documents/R/win-library/3.2/IS606/labs/Lab0")
source("more/arbuthnot.R")
We tabulate to vector the counts of girls baptized and plot them in a linear graph using the plot function. A brief analysis would reveal a generally positive trend to the data a drop in birthrates during the English Civil War.
plot(x = arbuthnot$year, y = arbuthnot$girls, type = "l")
The following plot is a proportion of boys over time. We see a relatively stable relationship, with a trend towards gradually increasing proportion of female births.
plot(arbuthnot$year, arbuthnot$boys / (arbuthnot$boys + arbuthnot$girls), type = "l")
We now load the second set of data of modern American birthrate data.
setwd("C:/Users/Robert/Documents/R/win-library/3.2/IS606/labs/Lab0")
source("more/present.R")
Now, let us answer the following questions.
What years are included in this data set? What are the dimensions of the data frame and what are the variable or column names?
We can answer these using the simple functions shown below.
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
dim(present)
## [1] 63 3
names(present)
## [1] "year" "boys" "girls"
How do these counts compare to Arbuthnot’s? Are they on a similar scale?
The modern-day data comprises of 19 fewer years however the mean annual sample size is 280 times greater than Arbuthnot’s.
nrow(present)-nrow(arbuthnot)
## [1] -19
mean(rowSums(present))/mean(rowSums(arbuthnot))
## [1] 280.7884
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.
We see a similar ratio of boys being born at a greater rate to women in the American dataset.
plot(present$year, present$boys / (present$boys + present$girls), type = "l")
In what year did we see the most total number of births in the U.S.?
present[order(rowSums(present), decreasing=T)[1],]$year
## [1] 1961