Lab 0

library(plyr)
source("more/arbuthnot.R")

Exercise 1

What command would you use to extract just the counts of girls baptized?

Answer: I would use the following command

paste("Total girls baprtized",sum(arbuthnot$girls))
## [1] "Total girls baprtized 453841"

Exercise 2

Is there an apparent trend in the number of girls baptized over the years? How would you describe it?

Answer : Yes the chart displays a downward trend 1640 to 1650 but then it is showing an upward trend starting 1660 going all the way up to 1700’s

plot(x = arbuthnot$year, y = arbuthnot$girls, type = "l")

Exercise 3

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.

ProportionOfBoys=arbuthnot$boys/arbuthnot$girls
Year=arbuthnot$year
plot(x = Year, y = ProportionOfBoys, type="l")

On Your Own

source("more/present.R")

Question 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?

YEARS

##  [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

## [1] 63  3

COLUMN NAMES

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

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

Answer : Based on the chart below the counts in the present data set is much larger than the counts in the Arbuthnot’s data set. The Arbuthnot’s data set starts with a count of 10000 where as the present data set the first year starts with a count of 2500000

plot(present$year,present$boys+present$girls,type="l")

plot(arbuthnot$year,arbuthnot$boys+arbuthnot$girls,type="l")

Question 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.

proportionOfBoys=present$boys/present$girls
plot(present$year,proportionOfBoys,type="l")

Question 4: 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

The Below result tells us that 1961 is in which there were the most number of total births in the U.S


```r
 df=rename(aggregate(present$boys+present$girls,list(present$year),max),c(Group.1="Year",x="count"))
i=max(df$count)
df[which(df$count == i), ]
```

```
##    Year   count
## 22 1961 4268326
```