title: Does stat_function() in ggplot2 work with args other than vectors?
body: <p>I am trying to print some values (geom_point) and on top of that draw some function (stat_function) with <code>ggplot2</code>, however I can't plot the function because it has an argument of type list.</p>
  
  <p>I want to print the function <code>create.new.func(x,W)</code> which gets two parameters (x,W) where x is a numeric value and W a list containing two matrices of different dimensions. I tried using the line </p>
  
  <pre><code>stat_function(fun= create.new.func,aes(colour="sep1"),args = list(W=superW))
  </code></pre>
  
  <p>However, I keep getting the following error:</p>
  
  <blockquote>
  <pre><code>Computation failed in `stat_function()`: non-conformable arguments##
  </code></pre>
  </blockquote>
  
  <p>Of course <code>create.new.func(x,W=superW)</code> works perfectly for any x.
  All the code snippet I have seen so far seem to use only vectors for the args parameter, hence my question.</p>
  
  <p>Example:</p>
  
  <pre><code>W &lt;- list(matrix(c(1, -1, -1, 1), nrow = 2), matrix(c(1, 2)))
  
  func &lt;- function(x, W){
      sum(W[[2]] * (W[[1]] %*% c(1, x)))
  }
  
  ggplot() + 
      geom_point(aes(x = 0, y = 0)) + 
      theme_bw()+
      stat_function(fun = func, args = list(W), aes(colour = "black")) +
      scale_colour_manual("data", values = c("blue"))
  </code></pre>