acf_tidiers {broom} | R Documentation |
Tidy an "acf" object, which is the output of acf
and the
related pcf
and ccf
functions.
## S3 method for class 'acf' tidy(x, ...)
x |
acf object |
... |
(not used) |
data.frame
with columns
lag |
lag values |
acf |
calucated correlation |
# acf result <- acf(lh, plot=FALSE) tidy(result) # ccf result <- ccf(mdeaths, fdeaths, plot=FALSE) tidy(result) # pcf result <- pacf(lh, plot=FALSE) tidy(result) # lag plot library(ggplot2) result <- tidy(acf(lh, plot=FALSE)) p <- ggplot(result, aes(x=lag, y=acf)) + geom_bar(stat='identity', width=0.1) + theme_bw() p # with confidence intervals conf.level <- 0.95 # from \code{plot.acf} method len.data <- length(lh) # same as acf$n.used conf.int <- qnorm((1 + conf.level) / 2) / sqrt(len.data) p + geom_hline(yintercept = c(-conf.int, conf.int), color='blue', linetype='dashed')