library(tidyverse)
library(openintro)
data('arbuthnot', package='openintro')arbuthnot$girls## [1] 4683 4457 4102 4590 4839 4820 4928 4605 4457 4952 4784 5332 5200 4910 4617
## [16] 3997 3919 3395 3536 3181 2746 2722 2840 2908 2959 3179 3349 3382 3289 3013
## [31] 2781 3247 4107 4803 4881 5681 4858 4319 5322 5560 5829 5719 6061 6120 5822
## [46] 5738 5717 5847 6203 6033 6041 6299 6533 6744 7158 7127 7246 7119 7214 7101
## [61] 7167 7302 7392 7316 7483 6647 6713 7229 7767 7626 7452 7061 7514 7656 7683
## [76] 5738 7779 7417 7687 7623 7380 7288
Insert any text here.
ggplot(data = arbuthnot, aes(x = year, y = girls)) +
geom_point()ggplot(data = arbuthnot, aes(x = year, y = girls)) +
geom_line()#There is a sharp decrease in girls being baptized during a 20 year period between 1640 and 1660.Additionally, the number of girls being baptized stays around 7,500 per year from 1690 yo 1710The ratio of boys baptized fluctuates year over year between .51 and .53.There appears to be more boys being baptized than girls during this time period.
arbuthnot <- arbuthnot %>%
mutate(total = boys + girls)
arbuthnot <- arbuthnot %>%
mutate(boy_ratio = (boys / total))
ggplot(data = arbuthnot, aes(x = year, y = boy_ratio)) +
geom_point()ggplot(data = arbuthnot, aes(x = year, y = boy_ratio)) +
geom_line()#Insert any text here.
data('present', package='openintro')
present$year## [1] 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954
## [16] 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969
## [31] 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984
## [46] 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999
## [61] 2000 2001 2002
dim(present)## [1] 63 3
dimnames(present)## [[1]]
## [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15"
## [16] "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30"
## [31] "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45"
## [46] "46" "47" "48" "49" "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "60"
## [61] "61" "62" "63"
##
## [[2]]
## [1] "year" "boys" "girls"
The dimensions of Arbuthnot contain 82 rows of information while Present only contains 63.
dim(present)## [1] 63 3
dim(arbuthnot)## [1] 82 5
dimnames(arbuthnot)## [[1]]
## [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15"
## [16] "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30"
## [31] "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45"
## [46] "46" "47" "48" "49" "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "60"
## [61] "61" "62" "63" "64" "65" "66" "67" "68" "69" "70" "71" "72" "73" "74" "75"
## [76] "76" "77" "78" "79" "80" "81" "82"
##
## [[2]]
## [1] "year" "boys" "girls" "total" "boy_ratio"
The ratio of boys being born in greater population appears to remain true in the US during the below time period as the boy ratio is higher than .50 indicating that over half the population is boy
present <- present %>%
mutate(total = boys + girls)
present<- present %>%
mutate(boy_ratio = (boys / total))
ggplot(data = present, aes(x = year, y = boy_ratio)) +
geom_point()ggplot(data = present, aes(x = year, y = boy_ratio)) +
geom_line()1961 saw the highest total number of births. Total was created in exercise 3.
present %>%
arrange(desc(total))## # A tibble: 63 × 5
## year boys girls total boy_ratio
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1961 2186274 2082052 4268326 0.512
## 2 1960 2179708 2078142 4257850 0.512
## 3 1957 2179960 2074824 4254784 0.512
## 4 1959 2173638 2071158 4244796 0.512
## 5 1958 2152546 2051266 4203812 0.512
## 6 1962 2132466 2034896 4167362 0.512
## 7 1956 2133588 2029502 4163090 0.513
## 8 1990 2129495 2028717 4158212 0.512
## 9 1991 2101518 2009389 4110907 0.511
## 10 1963 2101632 1996388 4098020 0.513
## # … with 53 more rows
## # ℹ Use `print(n = ...)` to see more rows