title: Receiving errors when trying to use stat_function in ggplot
body: <p>So my example data are:</p>
  
  <pre><code>x &lt;- runif(1000, min = 0, max = 5)
  y &lt;- (2 / pi) * atan(x)
  z &lt;- floor(x)
  df &lt;- data.frame(x, y, z)
  </code></pre>
  
  <p>I draw boxplots of x, binned by z:</p>
  
  <pre><code>library(ggplot2)
  g &lt;- ggplot(df, aes(x = x, y = y, group = z)) + 
    geom_boxplot()
  g
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/1ti6w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1ti6w.png" alt="enter image description here"></a></p>
  
  <p>But the thing is, in my real-life data, I'm not completely sure that the y-values follow <code>(2 / pi) * atan(x)</code>. There's a random element there. So, how do I draw the function on top of my graph to see for myself? As per the ggplot2 documentation, I tried...</p>
  
  <pre><code>g + stat_function(fun = (2 / pi) * atan(x), colour = "red")
  </code></pre>
  
  <p>...but am receiving the error <code>Warning message:
  Computation failed in 'stat_function()':
  'what' must be a function or character string</code>.</p>