title: Filter according to two conditions and a category in R
body: <p>What I intend to do is from a database, filter the rows according to two conditions, and then extract its other row with its same category.</p>
  <p>I show you my database.</p>
  <pre><code>    dat &lt;- read.table(text=&quot;
  Category  Score   Index    Document
  Pepe        5      Al           a
  Pepe        1      Bl           b
  Juan        8      Cl           a
  Juan        5      Al           b
  Mikel       1      Cl           a
  Mikel       6      Bl           b
  &quot;, header=TRUE
  </code></pre>
  <p>My intention is then to obtain the rows that meet two conditions. Index = Bl and Document=b. But not only get its rows, but also get the rows with the same category even if it does not meet the previous condition.</p>
  <p>That is, I want it to return this:</p>
  <p><a href="https://i.stack.imgur.com/pCzYU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pCzYU.png" alt="enter image description here" /></a></p>
  <p>Can you help me, please?</p>