title: Excel Goal seek in R
body: <p>I have calculated the required Safety Stock using the excel goal seek function. Below is the image.
  <img src="https://i.stack.imgur.com/a1GpG.png" alt="Goal Seek Using Excel">
   But now I want to do the same using R. </p>
  
  <p>The below function gives me the same excel results when I enter the SafetyStock &amp; SD. Now I need to do the reverse calculation(Whenever I provide x &amp; SD I need the SS). Could someone help me with the same?</p>
  
  <p>I tried Optix and other similar R packages but couldn't succeed.</p>
  
  <pre><code>opt&lt;-function(SS,SD){
  
    x=-SS*(1-pnorm(SS/SD)) + SD * dnorm(SS/SD,mean=0,sd =1,0)
    print(x)
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/41DUz.png" rel="nofollow noreferrer">Excel Goal seek </a></p>