title: Problem with implementing unitroot function in R
body: <p>I am new to programming, and I have been exposed to the basic of R and Python. I have been trying to implement the volatility smile function using a unit root function(a traditional procedure) but I am running into problems. Here is the code I am writing:</p>
  <pre><code>BlackScholesFormulaBach  &lt;- function (spot,timetomat,strike,r, q=0, sigma)
  { 
    
    d1&lt;-(spot-strike)/(sigma*sqrt(timetomat))
    d2&lt;-(spot-strike)/(sigma*sqrt(timetomat))
    
    
    result&lt;-(spot-strike)*pnorm(d1)+sigma*sqrt(timetomat)*dnorm(d1)
    
    
    BlackScholesFormulaBach&lt;-result
    
  }
  
  BlackScholesImpVol  &lt;- function (obsprice,spot,timetomat,strike,r, q=0)
    
  { difference&lt;- function(sigBS, obsprice,spot,timetomat,strike,r,q)
  {BlackScholesFormulaBach(spot,timetomat,strike,r,q,sigBS)-obsprice
  }
  
  uniroot(difference, c(-1,1),obsprice=obsprice,spot=spot,timetomat=timetomat,strike=strike,r=r,q=q)$root
  
  }
  
  S_0&lt;-100
  cap_T&lt;-1
  sigma_1&lt;-15
  N&lt;-1000
  
  BlackScholesImpVol(S_0,cap_T,1,0,0,15)
  </code></pre>
  <p>Every time I run the code I get:</p>
  <pre><code>Error in c(-1, 1) : unused argument (1)
  </code></pre>
  <p>If I change the interval I get the same error. I have been checking the code but it seems right. I have consulted other people and none finds the problem. According to R the problem is on the unitroot function, but I fail to see where.</p>
  <p>Question:</p>
  <p>Can someone help me solve this implementation problem?</p>
  <p>Thanks in Advnace</p>