title: How to get the 95th and 5th percentiles separately?
body: <p>I have data (e.g.d and di) that I want to do some calculations.</p>
  
  <p>data:</p>
  
  <pre><code>d= 1:20
  xi= 2:21
  </code></pre>
  
  <p>I would like to use this equation(using the 95th and 5th percentiles separately for both d and xi):</p>
  
  <pre><code>          res= d(95th)-d(5th)/xi(95th)+xi(5th)
            res2= res + xi(5th)
  </code></pre>
  
  <p>we get 95th and 5th percentiles using this function(provided by users of stackoverflow):</p>
  
  <pre><code>   fun &lt;- function(x){
  quantiles &lt;- quantile( x, c(.05, .95 ) )
  x[ x &lt; quantiles[1] ] &lt;- quantiles[1]
  x[ x &gt; quantiles[2] ] &lt;- quantiles[2]
  x
                    }
  </code></pre>
  
  <p>but this does not apply to my case as I want to use the 95th and 5th percentiles separately in the equation above.any ideas please.</p>