# DATA 606 Week 1 Assignment - Introduction to R and RStudio
# Student Name: Kalyan (Kalyanaraman Parthasarathy)
# install.packages(c('openintro','OIdata','devtools','ggplot2','psych','reshape2', 'knitr','markdown','shiny'))
# devtools::install_github("jbryer/DATA606")
# library('DATA606') # Load the package
# vignette(package='DATA606') # Lists vignettes in the DATA606 package
# vignette('os3') # Loads a PDF of the OpenIntro Statistics book
# data(package='DATA606') # Lists data available in the package
# getLabs() # Returns a list of the available labs
# viewLab('Lab0') # Opens Lab0 in the default web browser
# startLab('Lab0') # Starts Lab0 (copies to getwd()), opens the Rmd file
# shiny_demo() # Lists available Shiny apps
arbuthnot <- structure(list(
year = 1629:1710
, boys = c(
5218L, 4858L, 4422L,
4994L, 5158L, 5035L, 5106L, 4917L, 4703L, 5359L, 5366L, 5518L,
5470L, 5460L, 4793L, 4107L, 4047L, 3768L, 3796L, 3363L, 3079L,
2890L, 3231L, 3220L, 3196L, 3441L, 3655L, 3668L, 3396L, 3157L,
3209L, 3724L, 4748L, 5216L, 5411L, 6041L, 5114L, 4678L, 5616L,
6073L, 6506L, 6278L, 6449L, 6443L, 6073L, 6113L, 6058L, 6552L,
6423L, 6568L, 6247L, 6548L, 6822L, 6909L, 7577L, 7575L, 7484L,
7575L, 7737L, 7487L, 7604L, 7909L, 7662L, 7602L, 7676L, 6985L,
7263L, 7632L, 8062L, 8426L, 7911L, 7578L, 8102L, 8031L, 7765L,
6113L, 8366L, 7952L, 8379L, 8239L, 7840L, 7640L
)
, girls = c(4683L,
4457L, 4102L, 4590L, 4839L, 4820L, 4928L, 4605L, 4457L, 4952L,
4784L, 5332L, 5200L, 4910L, 4617L, 3997L, 3919L, 3395L, 3536L,
3181L, 2746L, 2722L, 2840L, 2908L, 2959L, 3179L, 3349L, 3382L,
3289L, 3013L, 2781L, 3247L, 4107L, 4803L, 4881L, 5681L, 4858L,
4319L, 5322L, 5560L, 5829L, 5719L, 6061L, 6120L, 5822L, 5738L,
5717L, 5847L, 6203L, 6033L, 6041L, 6299L, 6533L, 6744L, 7158L,
7127L, 7246L, 7119L, 7214L, 7101L, 7167L, 7302L, 7392L, 7316L,
7483L, 6647L, 6713L, 7229L, 7767L, 7626L, 7452L, 7061L, 7514L,
7656L, 7683L, 5738L, 7779L, 7417L, 7687L, 7623L, 7380L, 7288L
)
)
, .Names = c("year", "boys", "girls")
, class = "data.frame"
, row.names = c(NA, -82L)
)
source("http://www.openintro.org/stat/data/arbuthnot.R")
arbuthnot
dim(arbuthnot)
names(arbuthnot)
arbuthnot$boys
# Exercise 1 - What command would you use to extract just the counts of girls baptized? Try it!
sum(arbuthnot$girls)
plot(x = arbuthnot$year, y = arbuthnot$girls)
# Plot with lines
plot(x = arbuthnot$year, y = arbuthnot$girls, type = "l")
plot(x = arbuthnot$year, y = arbuthnot$boys)
plot(x = arbuthnot$year, y = arbuthnot$boys, type = "l")
# ?plot
# Exercise 2 - Is there an apparent trend in the number of girls baptized over the years? How would you describe it?
# Answer: Yes, there is a trend in the number of girls baptized. Overall, there is an upward trend in girls baptized over the years however there is a sharp decline after reaching new record levels (years 1650, 1659, 1666, 1704)
# Also there is an observation that Boys and Girls baptized rates are higher - going hand on hand
#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.
plot(x=arbuthnot$year, y=arbuthnot$boys / (arbuthnot$girls + arbuthnot$boys), type = "l")
# Observation: Overall the percentage of Boys baptized is more compared to Girls, especially between the years 1660 and 1680.