In the previous few pages, you recreated some of the displays and preliminary analysis of Arbuthnot’s baptism data. Your assignment involves repeating these steps, but for present day birth records in the United States. Load up the present day data with the following command.
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?
The years are 1940-2002. There are 63 rows and 3 columns. The data set’s columns are: year, boys, girls
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?
Arbuthnot’s has more rows than Present, but same number of columns
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.
Based on the plot, the boy-to-girl ratio is greater than 1 in the present dataset, same as in the Arbuthnot’s
plot(present$year, present$boys / present$girls)In what year did we see the most total number of births in the U.S.? You can refer to the help files or the R reference card http://cran.r-project.org/doc/contrib/Short-refcard.pdf to find helpful commands.
Between 1940-2002, it was in 1961 that had the most births in the U.S.
max(present$boys+present$girls)## [1] 4268326
present[which.max(present$boys + present$girls),]## year boys girls
## 22 1961 2186274 2082052
These data come from a report by the Centers for Disease Control http://www.cdc.gov/nchs/data/nvsr/nvsr53/nvsr53_20.pdf. Check it out if you would like to read more about an analysis of sex ratios at birth in the United States.
That was a short introduction to R and RStudio, but we will provide you with more functions and a more complete sense of the language as the course progresses. Feel free to browse around the websites for R and RStudio if you’re interested in learning more, or find more labs for practice at http://openintro.org.
This is a product of OpenIntro that is released under a Creative Commons Attribution-ShareAlike 3.0 Unported. This lab was adapted for OpenIntro by Andrew Bray and Mine Çetinkaya-Rundel from a lab written by Mark Hansen of UCLA Statistics.