Load data from present.R located in working directory/more folder and also creates data frame.

source("more/present.R")

Load data from arbuthnot.R located in working directory/more folder and also creates data frame. We will use this later to compare with present data set.

source("more/arbuthnot.R")
present
##    year    boys   girls
## 1  1940 1211684 1148715
## 2  1941 1289734 1223693
## 3  1942 1444365 1364631
## 4  1943 1508959 1427901
## 5  1944 1435301 1359499
## 6  1945 1404587 1330869
## 7  1946 1691220 1597452
## 8  1947 1899876 1800064
## 9  1948 1813852 1721216
## 10 1949 1826352 1733177
## 11 1950 1823555 1730594
## 12 1951 1923020 1827830
## 13 1952 1971262 1875724
## 14 1953 2001798 1900322
## 15 1954 2059068 1958294
## 16 1955 2073719 1973576
## 17 1956 2133588 2029502
## 18 1957 2179960 2074824
## 19 1958 2152546 2051266
## 20 1959 2173638 2071158
## 21 1960 2179708 2078142
## 22 1961 2186274 2082052
## 23 1962 2132466 2034896
## 24 1963 2101632 1996388
## 25 1964 2060162 1967328
## 26 1965 1927054 1833304
## 27 1966 1845862 1760412
## 28 1967 1803388 1717571
## 29 1968 1796326 1705238
## 30 1969 1846572 1753634
## 31 1970 1915378 1816008
## 32 1971 1822910 1733060
## 33 1972 1669927 1588484
## 34 1973 1608326 1528639
## 35 1974 1622114 1537844
## 36 1975 1613135 1531063
## 37 1976 1624436 1543352
## 38 1977 1705916 1620716
## 39 1978 1709394 1623885
## 40 1979 1791267 1703131
## 41 1980 1852616 1759642
## 42 1981 1860272 1768966
## 43 1982 1885676 1794861
## 44 1983 1865553 1773380
## 45 1984 1879490 1789651
## 46 1985 1927983 1832578
## 47 1986 1924868 1831679
## 48 1987 1951153 1858241
## 49 1988 2002424 1907086
## 50 1989 2069490 1971468
## 51 1990 2129495 2028717
## 52 1991 2101518 2009389
## 53 1992 2082097 1982917
## 54 1993 2048861 1951379
## 55 1994 2022589 1930178
## 56 1995 1996355 1903234
## 57 1996 1990480 1901014
## 58 1997 1985596 1895298
## 59 1998 2016205 1925348
## 60 1999 2026854 1932563
## 61 2000 2076969 1981845
## 62 2001 2057922 1968011
## 63 2002 2057979 1963747

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

A: Total of 63 years from 1940 to 2002.

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 of the data frame present

dim(present)
## [1] 63  3

Columns in the data frame are

names(present)
## [1] "year"  "boys"  "girls"

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

A: Present data frame counts are much higher than Arbuthnot counts and also they belong to different period of time. Present data frame years range from 1940 to 2002 on the other hand Arbuthnot data frame years range from 1629 - 1710. They are similar scale as

– Both data frames have 3 columns – Both data frame have year column as categorical variable and boys and girls as numerical variables.

dim(arbuthnot)
## [1] 82  3

Q 3: 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.

Calculate boy-to-girl ratio. We will add extra column “boyTogirlratio” to data frame present.

present$boyTogirlratio <- present$boys / present$girls
present$boyTogirlratio
##  [1] 1.054817 1.053969 1.058429 1.056767 1.055757 1.055391 1.058698
##  [8] 1.055449 1.053820 1.053760 1.053716 1.052078 1.050934 1.053399
## [15] 1.051460 1.050742 1.051286 1.050672 1.049374 1.049480 1.048873
## [22] 1.050057 1.047948 1.052717 1.047188 1.051137 1.048540 1.049964
## [29] 1.053417 1.052997 1.054719 1.051845 1.051271 1.052129 1.054797
## [36] 1.053605 1.052538 1.052569 1.052657 1.051749 1.052837 1.051615
## [43] 1.050597 1.051976 1.050199 1.052061 1.050876 1.050000 1.049991
## [50] 1.049720 1.049676 1.045849 1.050017 1.049955 1.047877 1.048928
## [57] 1.047062 1.047643 1.047190 1.048791 1.047998 1.045686 1.047986
subset(present, select=c(year, boyTogirlratio))
##    year boyTogirlratio
## 1  1940       1.054817
## 2  1941       1.053969
## 3  1942       1.058429
## 4  1943       1.056767
## 5  1944       1.055757
## 6  1945       1.055391
## 7  1946       1.058698
## 8  1947       1.055449
## 9  1948       1.053820
## 10 1949       1.053760
## 11 1950       1.053716
## 12 1951       1.052078
## 13 1952       1.050934
## 14 1953       1.053399
## 15 1954       1.051460
## 16 1955       1.050742
## 17 1956       1.051286
## 18 1957       1.050672
## 19 1958       1.049374
## 20 1959       1.049480
## 21 1960       1.048873
## 22 1961       1.050057
## 23 1962       1.047948
## 24 1963       1.052717
## 25 1964       1.047188
## 26 1965       1.051137
## 27 1966       1.048540
## 28 1967       1.049964
## 29 1968       1.053417
## 30 1969       1.052997
## 31 1970       1.054719
## 32 1971       1.051845
## 33 1972       1.051271
## 34 1973       1.052129
## 35 1974       1.054797
## 36 1975       1.053605
## 37 1976       1.052538
## 38 1977       1.052569
## 39 1978       1.052657
## 40 1979       1.051749
## 41 1980       1.052837
## 42 1981       1.051615
## 43 1982       1.050597
## 44 1983       1.051976
## 45 1984       1.050199
## 46 1985       1.052061
## 47 1986       1.050876
## 48 1987       1.050000
## 49 1988       1.049991
## 50 1989       1.049720
## 51 1990       1.049676
## 52 1991       1.045849
## 53 1992       1.050017
## 54 1993       1.049955
## 55 1994       1.047877
## 56 1995       1.048928
## 57 1996       1.047062
## 58 1997       1.047643
## 59 1998       1.047190
## 60 1999       1.048791
## 61 2000       1.047998
## 62 2001       1.045686
## 63 2002       1.047986

As the year progresses, the ratio reduces. In the year 1946, there were more boys born compared to girls. After 1946 difference started reducing. Yes, Arbuthnot’s observation about boys being born in greater proportion than girls holds good in the U.S. too. Following is the plot displaying years and boy-to-girl ratio.

plot(x=present$year, y=present$boyTogirlratio,xlab="Year",ylab="boy-to-girl ratio", type = "l")

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

Seems Most births happened in year 1961, total of 4268326.

present$totalbirth <- present$boys + present$girls
present[present$totalbirth == max(present$totalbirth),]
##    year    boys   girls boyTogirlratio totalbirth
## 22 1961 2186274 2082052       1.050057    4268326

Apendix

source("more/present.R")
source("more/arbuthnot.R")
present
present$year
dim(present)
names(present)
dim(arbuthnot)
present$boyTogirlratio <- present$boys / present$girls
present$boyTogirlratio
subset(present, select=c(year, boyTogirlratio))
plot(x=present$year, y=present$boyTogirlratio,xlab="Year",ylab="boy-to-girl ratio", type = "l")
present$totalbirth <- present$boys + present$girls
present[present$totalbirth == max(present$totalbirth),]