title: Recycling array of length 1 in array-vector arithmetic is deprecated. Optimization Sum of Squared Errors
body: <p>I need to find the optimal weight (a) to minimize sum of squared errors. I use this as an example as I'll have a more complex problem to work on which requires the use of some other optimization packages but lm. I receive warnings() saying that "In a * y. Recycling array of length 1 in array-vector arithmetic is deprecated. Use c() or as.vector() instead." I tried as.vector(a * y), a[1] * y, a * as.vector(y) but nothing works. </p>
  
  <p>What should I do to get rid of this message?</p>
  
  <pre><code>install.packages("NlcOptim")
  library(NlcOptim)
  
  x &lt;- c(1:4)
  y &lt;- c(2,4,6,8)
  
  objfun &lt;- function(a) {
    return(sum((x-a*y)^2))
  }
  x0 &lt;- 1
  solnl(x0,objfun = objfun)
  
  </code></pre>
  
  <p>Here is the error message that I see after typing <code>warnings()</code>:</p>
  
  <pre><code>1: In a * y :
    Recycling array of length 1 in array-vector arithmetic is deprecated.
    Use c() or as.vector() instead.
  </code></pre>