library(tidyverse)
library(openintro)length(arbuthnot$girls)## [1] 82
I found a increase linear regression trend, and the number of girls baptized increasing over the years.
ggplot(data = arbuthnot, aes(x=year, y=girls)) +
geom_point() +
stat_smooth(method="lm", col= "red")## `geom_smooth()` using formula 'y ~ x'
I found a decreased linear regression trend, and the boy’s ratio decreased over the years.
total <- arbuthnot$boys + arbuthnot$girls
ggplot(data = arbuthnot, aes(x=year, y=boys/total)) +
geom_line() +
stat_smooth(method="lm", col= "red")## `geom_smooth()` using formula 'y ~ x'
Year 1940 ~ 2002 63 rows 3 columns 3 variable : year, boys, girls
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
names(present)## [1] "year" "boys" "girls"
arbuthnot > present, their not similar magnitude.
length(total)## [1] 82
length(present$girls + present$boys)## [1] 63
I found a decreased linear regression trend, and the boy’s ratio decreased over the years in US.
total <- present$boys + present$girls
ggplot(data = present, aes(x=year, y=boys/total)) +
geom_line() +
stat_smooth(method="lm", col= "red")## `geom_smooth()` using formula 'y ~ x'
Year 1961
present$year[which.max(present$boys +present$girls)]## [1] 1961
present <- present %>%
mutate(total = boys + girls)
present %>%
arrange(desc(total))## # A tibble: 63 × 4
## year boys girls total
## <dbl> <dbl> <dbl> <dbl>
## 1 1961 2186274 2082052 4268326
## 2 1960 2179708 2078142 4257850
## 3 1957 2179960 2074824 4254784
## 4 1959 2173638 2071158 4244796
## 5 1958 2152546 2051266 4203812
## 6 1962 2132466 2034896 4167362
## 7 1956 2133588 2029502 4163090
## 8 1990 2129495 2028717 4158212
## 9 1991 2101518 2009389 4110907
## 10 1963 2101632 1996388 4098020
## # … with 53 more rows