title: Apply a function to each row in a data.frame and append the result to the data.frame in R
body: <p>It seems like I should either know how to do this or at least find the answer here or elsewhere. Unfortunately neither is working.</p>
  
  <p>I have a data frame of customers where one column is their id and another column is their full address. I want to add 3 columns for each row with the lat, long and county code from a geocode lookup.</p>
  
  <p>That data frame looks like</p>
  
  <pre><code>customer_id       fulladdress
       1            123 Main St., Anywhere, FL
       2            321 Oak St., Thisplace, CA
  </code></pre>
  
  <p>I created a geocode function that takes the full address and returns a data frame with lat, long and county columns.</p>
  
  <p>How can I apply my geocode function to each row of the data frame and append the results as 3 columns into the existing data frame so that it looks like this:</p>
  
  <pre><code>customer_id       fulladdress                      lat        long     county
       1            123 Main St., Anywhere, FL     33.2345    -92.3333   43754
       2            321 Oak St., Thisplace, CA     25.3333    -120.333   32960
  </code></pre>
  
  <p>I've tried playing with apply and ddply, but I can't seem to figure out what either one is doing. I tried this with ddply but all it does is give me back the original data frame.</p>
  
  <pre><code>ddply(customers[1:3,], .(fulladdress), function(x) { geocode(x$fulladdress)})
  </code></pre>
  
  <p>Thanks for the help.</p>