title: Apply GBSVolatility to each row
body: <p>I have a rather simple question but unfortunately just cannot get to a result:
  I would like to apply the GBSVolatility function to each row of my data.frame.</p>
  
  <p>I did the following:</p>
  
  <pre><code>&gt; vol &lt;- function(x) GBSVolatility(x$Price, "c", S = 1000, x$Strike, Time = 1/4, 
  r = 0.01, b = 0.02, maxiter = 500)
  &gt; foo$iv &lt;- apply(foo, 1, vol)
  </code></pre>
  
  <p>But this does not work. Can someone tell me why?</p>
  
  <p>Thanks alot</p>
  
  <p>Dani</p>
  
  <p><strong>Update:</strong>
  Thank you for your suggestion. My data frame is called foo and looks like this</p>
  
  <pre><code>Date Price Strike Name
  1.1  100   1200    X
  1.1  120   1500    P
  etc.
  </code></pre>
  
  <p>I would like to make a new column with the implied volatility. I tried to apply, </p>
  
  <pre><code>vol &lt;- function(x) GBSVolatility(x["Price"], "c", S = 1000, x["Strike"], 
       Time = 1/4,  r = 0.01, b = 0.02, maxiter = 500)
  foo$iv &lt;- apply(foo, 1, vol)
  </code></pre>
  
  <p>but it didn't work as well.</p>
  
  <p>Do you have any other suggestions? Thanks</p>