title: R: How to implement Benjamini-Hochberg in R?
body: <p>Here's the codes I've attempted so far: v=vector of p values, alpha=target FDR</p>
  
  <pre><code>bh=function(v,alpha=.1){
      sorted.v&lt;-sort(v)    
      dif&lt;-sorted.v-alpha
      neg.dif&lt;-dif[dif&lt;0]
      pos.dif&lt;-neg.dif[length(neg.dif)]
      index&lt;-dif==pos.dif
      p.cutoff&lt;-sorted.v[index]
      ## (Comment:below will return the cutoff value)
      p.cutoff
      p.sig&lt;-v[v&lt;=p.cutoff]
      ## (comment:below will return p-values that are significant.)
      p.sig
  }
  </code></pre>
  
  <p>Would this work?
  Any help will be greatly appreciated.
  Thank you very much!</p>