title: Using Grep function with for loop
body: <p>I'm having a problem with my code. This works for other values when the ID values are all in the tag matrix, however, if there's a value in the ID that's not in the tag matrix I get the error: </p>
  
  <pre><code>Error in IDintag[i] &lt;- grep(ID[i], tag) : replacement has length zero
  </code></pre>
  
  <p>Thanks in advance</p>
  
  <pre><code>tag=NULL
  ID=NULL
  
  url &lt;- readLines("http://www.afip.gob.ar/contacto")
  tag &lt;- as.matrix(grep("&lt;/strong&gt;",url))
  ID &lt;- grep("correo",url)
  
  for(i in 1:length(ID))
      {IDintag[i] &lt;- grep(ID[i],tag)
      }
  </code></pre>