title: R code: i got NA as result when i am calling my functon
body: <p>When I call my function it show NA?<br> Although, when I'm sending different parameters it works. So my question how many results should be one or two for each call and why sometimes i got NA.</p>
  
  <p>Here is my code:  </p>
  
  <pre><code>trsp&lt;-function(x,p,tr,mlo,mhi)
   {
    mm&lt;-seq(mlo, mhi, length =101)
    w&lt;-double(length (mm))
    for (k in 1:101)
    {
      xmm&lt;-sort(abs((x-mm[k]))^p)
      w[k]&lt;-sum(xmm[c(1:ceiling(tr*length(x)))])
    }
    mmw&lt;-cbind(mm, w)
    plot(mmw)
    mmw[w&lt;-min(w)]
   }  
  
  dta&lt;-rcauchy(23)
  
  trsp(dta,1,1,0,1)
  trsp(dta,2,1,0,1)
  trsp(dta,1,0.6,0,1)
  trsp(dta,2,0.6,0,1)
  trsp(dta,0.5,0.6,0,1)
  </code></pre>