title: R. How to append loop (for) results into a Data Frame?
body: <p>I´m trying to build a dataframe with some brazilian address by accessing a web service and searching for a zip code. 
  Actually, I´m able to receive one single result and store it in a dataframe, but when I try to search for multiple zip codes (e.g in a vector), my dataframe is only keep the last element.
  Could anybody help me please?</p>
  
  <p>See the code below:</p>
  
  <pre><code>###############
  library(httr)
  library(RCurl)
  library(XML)
  library(dplyr)
  ###############
  
  # ZIPs I want to search for:
  vectorzip &lt;- c("71938360", "70673052", "71020510")
  j &lt;- length(vectorzip)
  
  # loop:
  for(i in 1:j) {
  
  # Save the URL of the xml file in a variable:
  xml.url &lt;- getURL(paste("http://cep.republicavirtual.com.br/web_cep.php?cep=",vectorzip[i], sep = ""), encoding = "ISO-8859-1")
  xml.url
  
  # Use the xmlTreeParse-function to parse xml file directly from the web:
  xmlfile &lt;- xmlTreeParse(xml.url)
  xmlfile
  # the xml file is now saved as an object you can easily work with in R:
  class(xmlfile)
  
  # Use the xmlRoot-function to access the top node:
  xmltop = xmlRoot(xmlfile)
  
  # have a look at the XML-code of the first subnodes:
  print(xmltop)
  
  # To extract the XML-values from the document, use xmlSApply:
  zips &lt;- xmlSApply(xmlfile, function(x) xmlSApply(x, xmlValue))
  zips
  # Finally, get the data in a data-frame and have a look at the first rows and columns:
  zips &lt;- NULL
  zips &lt;- rbind(zips_df, data.frame(t(zips),row.names=NULL))
  
  View(zips_df)}
  </code></pre>