ap_df <- tsdf(AirPassengers)
# default additive decomposition (doesn't work well in this case!):
ggplot(ap_df, aes(x = x, y = y)) +
stat_decomp(frequency = 12)
# multiplicative decomposition, more appropriate:
ggplot(ap_df, aes(x = x, y = y)) +
stat_decomp(frequency = 12, type = "multiplicative")
ggplot(ldeaths_df, aes(x = YearMon, y = deaths, colour = sex)) +
geom_point() +
facet_wrap(~sex) +
stat_decomp(frequency = 12) +
ggtitle("Seasonally adjusted lung deaths")Run the code above in your browser using DataLab