title: Error in first function: $ operator is invalid for atomic vectors
body: <p>Disclaimer: This is my first time trying to create a function in R.</p>
  
  <p>I have HoltWinters function that looks like this:</p>
  
  <pre><code>f &lt;- function(x) {
      y &lt;- ts(x$Million, freq = 4, start = c(2013, 1))
      y.hw &lt;- HoltWinters(y)
      y.pr &lt;- forecast(y.hw, h = 3, level = c(80, 85))
      y.pr
      plot(y.pr)
  }
  </code></pre>
  
  <p>It takes a dataframe, converts it to timeseries (<code>ts</code>), forecasts and plots the forecast. </p>
  
  <p>I am getting thrown this error:</p>
  
  <blockquote>
    <p>Error in x$Million : $ operator is invalid for atomic vectors</p>
  </blockquote>
  
  <p>I know this is probably a stupid question... but I hope you'll be nice!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The structure of the dataframes I want to pass to the function:</p>
  
  <pre><code>    Quarter Product Million
  1   2013-Q1 AAA     4.0
  2   2013-Q2 AAA     6.0
  3   2013-Q3 AAA     9.0
  </code></pre>