title: Merge dataframes based on overlapping genomic ranges
body: <p>I have two files:</p>
  
  <p>anno</p>
  
  <pre><code>  chromosome position functionGVS
  1      chr22 16050036  intergenic
  2      chr22 16050039  intergenic
  3      chr22 16050094  intergenic
  4      chr22 16050097  intergenic
  5      chr22 16050109  intergenic
  6      chr22 16050115  intergenic
  </code></pre>
  
  <p>huvec</p>
  
  <pre><code>    chr    start      end function
  1 chr22 16050000 16051244  R
  2 chr22 16051244 16051521  T
  3 chr22 16051521 16060433  R
  4 chr22 16060433 16060582  T
  5 chr22 16060582 16080564  R
  6 chr22 16080564 16082420  T
  </code></pre>
  
  <p>I am trying to find overlapping regions such that the anno$position should fall within the range of huvec$start &amp; huvec$end. Here is my code:</p>
  
  <pre><code>gr.huvec = with(huvec, GRanges(V1, IRanges(start=V2,end=V3)))
  
  gr.anno &lt;- GRanges(seqnames=anno$chromosome, ranges=IRanges(start=anno$position, width=1))
  
  hits = findOverlaps(gr.huvec,gr.anno)
  </code></pre>
  
  <p>My question is that now, after I have the query hits &amp; subject hits, how can I assign huvec$function to anno based on overlapping regions. So in my case, each position in anno$position overlaps with the first start &amp; end values of huvec and so I want to assign the associated huvec$function i.e. 'R' to a new column in anno. Any suggestions?</p>