# load libraries for models and data
library(zoo)
library(ggplot2)
set.seed(1071)
# generate data
Z.index <- as.Date(sample(12450:12500, 10))
Z.data <- matrix(rnorm(30), ncol = 3)
colnames(Z.data) <- c("Aa", "Bb", "Cc")
Z <- zoo(Z.data, Z.index)
# summarize model fit with tidiers + visualization
tidy(Z)
ggplot(tidy(Z), aes(index, value, color = series)) +
geom_line()
ggplot(tidy(Z), aes(index, value)) +
geom_line() +
facet_wrap(~series, ncol = 1)
Zrolled <- rollmean(Z, 5)
ggplot(tidy(Zrolled), aes(index, value, color = series)) +
geom_line()
Run the code above in your browser using DataLab