title: Improving acf function and getting certain values
body: <p>I have some problems connected with auto correlation function. Let's have a look at code following :</p>
  <pre><code>acf_plot&lt;-function(vec,lag_max){
    val_acf &lt;- acf(vec, plot = FALSE,lag.max = lag_max)
    df &lt;- with(val_acf, data.frame(lag, acf))
    ggplot(data = df, mapping = aes(x = lag, y = acf)) +
      geom_hline(aes(yintercept = 0)) +
      geom_segment(mapping = aes(xend = lag, yend = 0))+ scale_y_continuous(breaks=c(-1,-0.75,-0.5,-0.25,0.25,0.50,0.75))
  }
  
  set.seed(20)
  x&lt;-runif(100)
  acf(x)
  acf_plot(vec=x,lag_max=30)
  </code></pre>
  <p>Function <code>acf_plot()</code> is creating acf function with respect to ggplot. The problem is during creation my confidence interval on the image is being omitted (You can see lack of blue line in the ggplot below).</p>
  <p><a href="https://i.stack.imgur.com/pO3KM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pO3KM.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/LffrE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LffrE.png" alt="enter image description here" /></a></p>
  <p>To summarize I have two questions to you guys</p>
  <p>(1) Is there any possibility to add blue line to that ggplot graph ? i.e. that confidence interval will be also included in acf ggplot.</p>
  <p>(2) My second question is, how can I extract values of 95% confidence interval in acf ? I mean the exactly values behind those blue lines. I read <a href="https://stackoverflow.com/questions/14266333/extract-confidence-interval-values-from-acf-correlogram">Extract confidence interval values from ACF correlogram</a> but I didn't get the point they were writing about. I tried to do it analogously but I failed. Can you guys help me with those two problems ?</p>