data(Births78)
data(Births2015)
data(Births)
data(BirthsSSA)
data(BirthsCDC)
# date ranges for the different data sets
lapply(
list(Births = Births, Births78 = Births78, Biths2015 = Births2015, BirthsSSA = BirthsSSA,
BirthsCDC = BirthsCDC),
function(x) range(x$date))
range(Births78$date)
range(Births2015$date)
range(Births$date)
range(BirthsSSA$date)
range(BirthsCDC$date)
# Births and Births78 have slightly different numbers of births
if(require(ggplot2)) {
ggplot(data = Births, aes(x = date, y = births, colour = ~ wday)) +
stat_smooth(se = FALSE, alpha = 0.8, geom = "line")
ggplot(data = Births, aes(x = day_of_year, y = births, colour = ~ wday)) +
geom_point(size = 0.4, alpha = 0.5) +
stat_smooth(se = FALSE, geom = "line", alpha = 0.6, size = 1.5)
if (require(dplyr)) {
ggplot(
data = bind_cols(Births |> filter(year == 1978),
Births78 |> rename(births78 = births)),
aes(x = births - births78)
) +
geom_histogram(binwidth = 1)
}
}
if(require(ggplot2)) {
ggplot(data = Births, aes(x = date, y = births, colour = ~ wday)) +
stat_smooth(se = FALSE, alpha = 0.8, geom = "line")
ggplot(data = Births, aes(x = day_of_year, y = births, colour = ~ wday)) +
geom_point(size = 0.4, alpha = 0.5) +
stat_smooth(se = FALSE, geom = "line", alpha = 0.6, size = 1.5)
if (require(dplyr)) {
ggplot(
data = bind_cols(Births |> filter(year == 1978),
Births78 |> rename(births78 = births)),
aes(x = births - births78)
) +
geom_histogram(binwidth = 1)
# SSA records more births than CDC
ggplot(
data = bind_cols(BirthsSSA |> filter(year <= 2003) |> rename(SSA = births),
BirthsCDC |> filter(year >= 2000) |> rename(CDC = births)),
aes(x = SSA - CDC)
) +
geom_histogram(binwidth = 10)
}
}
Run the code above in your browser using DataLab