title: How to find the existence of specific name between one other name in dataframe?
body: <p>I have a data frame and as an example you can see part of it below:</p>
  
  <pre><code>name=c("ENS1","ENS1","ENS1", "ENS2", "ENS2", "ENS2","ENS2", "ENS2", "ENS2")
  position=c("chr1", "chr1", "chr1", "chr2", "chr2", "chr2", "chr2", "chr2", "chr2")
  dif=c("mir1","ENS1","ENS1", "ENS2", "mir4", "mir2","mir3", "ENS2", "mir1")
  data=data.frame(name,position,dif)
  </code></pre>
  
  <p>Now, I want to know is there any <code>mir</code> between two same <code>ENS</code> or not and also I want to know for which <code>ENS</code> I have <code>mir</code> before it?</p>
  
  <p>So I need some codes to get result like this:</p>
  
  <pre><code>ENS1  FALSE (No mir in between)
  
  ENS2  TRUE (mir in between)
  </code></pre>