title: Trying to loop through a dataframe and reference multiple fields
body: <p>I have a dataframe with Address, City, State, Zip entities.  From there, I'm trying to use the Yahoo APIs to Geocode each address.</p>
  
  <p>I'm basing this off the code in O'Reilly's Data Mashups using R Tutorial.  The original example takes a vector of street addresses and uses a hard-coded city.  I'm trying to make a dynamic example that supports multiple cities.</p>
  
  <p>The abbreviated version of the code is:</p>
  
  <pre><code>    geocodeAddresses&lt;-function(myStreets)
      }
    appid&lt;-'&lt;put your appid here&gt;'
            baseURL&lt;-"http://local.yahooapis.com/MapsService/V1/geocode?appid="
            myGeoTable&lt;-data.frame(address=character(),lat=numeric(),long=numeric(),EID=numeric())
            for (myStreet in myStreets){  
              requestUrl&lt;-paste(baseURL, appid, "&amp;street=", URLencode(myStreet$address),"&amp;city=",URLencode(myStreet$city),"&amp;state=",URLencode(myStreet$state),sep="")
              xmlResult&lt;-xmlTreeParse(requestUrl,isURL=TRUE,addAttributeNamespaces=TRUE)
              geoResult&lt;-xmlResult$doc$children$ResultSet$children$Result
              lat&lt;-xmlValue(geoResult[['Latitude']])
              long&lt;-xmlValue(geoResult[['Longitude']])
              myGeoTable&lt;-rbind(myGeoTable,data.frame(address=myStreet,Y=lat,X=long,EID=NA))
            }
      }
  </code></pre>
  
  <p>When I try and reference myStreet$City and myStreet$Address, I receive an error</p>
  
  <pre><code>$ operator is invalid for atomic vectors
  </code></pre>
  
  <p>Other than looping through data frame myStreets, I don't know how I can make the call to the Yahoo API only once for each row and store both the long/lat for each member.</p>