title: Passing a data frame column in a function: Unknown or uninitialised column
body: <p>I am trying to create a simple function based on ggplot2 to save space. </p>
  
  <p>Example data: </p>
  
  <pre><code>X &lt;- rep(c(9:15), each = 9)
  ID &lt;- rep(c(2:8), each = 9)
  Attitude &lt;- rep(c('A1', 'A2','A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9'), 7)
  Answer_a &lt;- rep(1:5, length.out = 63)
  time &lt;- as.character(rep(c(0, 1, 3), each = 21))
  first_answer &lt;- rep(1:5, length.out = 63)
  
  df &lt;- data.frame(X, ID, Attitude, Answer_a, time, first_answer)
  df$time &lt;- as.character(df$time)
  </code></pre>
  
  <p>The code for the function I am trying to create: </p>
  
  <pre><code>spaghetti_plot &lt;- function(input, MV, item_level){
  
    p &lt;- ggplot(na.omit(input[ which(input$MV == item_level), ]), 
       aes( x = time, y = Answer_a, group = ID))
    p &lt;- p + geom_line(aes(colour = first_answer))
    return(p)
  }
  </code></pre>
  
  <p>So in essence my question is why I get the warning message <code>Warning: Unknown or uninitialised column</code> when I use the function as follows:</p>
  
  <p>spaghett_plot(df, Attitude, 'A1')</p>