title: Using the grep function in a for loop in R
body: <p>I have two matrices of different sizes and need to check if there are any matching numerical values in them. So far I have:</p>
  
  <pre><code>url &lt;- readLines("http://www.afip.gob.ar/contacto")
  x &lt;- as.matrix(grep("&lt;strong&gt;",url))
  x2 &lt;- grep("Centro|prima|Operaciones de Seguro",url)
  for(i in 1:length(x2))
  {x3 &lt;-(grep(x2[i],x))
  }
  </code></pre>
  
  <p>The data is fine since if I enter:</p>
  
  <pre><code>x3 &lt;- grep(x2[1],x)
  </code></pre>
  
  <p>It gives me that x3 = 1 as it should.</p>
  
  <p>Thanks in advance</p>