title: Getting "Error in as.vector(x.mode): cannot coerce type 'closure' to vector of type 'any'"
body: <p>I keep getting the following error. </p>
  
  <pre><code>Error in as.vector(x, mode) : 
    cannot coerce type 'closure' to vector of type 'any'
  </code></pre>
  
  <p>I want to plot f2(x) versus x using the matplot option in RStudio. Is there something I'm missing?</p>
  
  <pre><code>f2&lt;-function(x){
    if(x&gt;=0){
      return(sqrt(x))
    }else{
      return(sqrt(-x))
    }
  }
  
  x&lt;- seq(from= -5, to= 5, by= 0.001)
  
  require(graphics)
  matplot(f2, x, type = "1", xlab = expression(alpha), ylab = expression(sqrt(abs(alpha)))) 
  </code></pre>