Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 379399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:53:17+00:00 2026-05-12T14:53:17+00:00

I have a dataframe with Address, City, State, Zip entities. From there, I’m trying

  • 0

I have a dataframe with Address, City, State, Zip entities. From there, I’m trying to use the Yahoo APIs to Geocode each address.

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.

The abbreviated version of the code is:

    geocodeAddresses<-function(myStreets)
    }
  appid<-'<put your appid here>'
          baseURL<-"http://local.yahooapis.com/MapsService/V1/geocode?appid="
          myGeoTable<-data.frame(address=character(),lat=numeric(),long=numeric(),EID=numeric())
          for (myStreet in myStreets){  
            requestUrl<-paste(baseURL, appid, "&street=", URLencode(myStreet$address),"&city=",URLencode(myStreet$city),"&state=",URLencode(myStreet$state),sep="")
            xmlResult<-xmlTreeParse(requestUrl,isURL=TRUE,addAttributeNamespaces=TRUE)
            geoResult<-xmlResult$doc$children$ResultSet$children$Result
            lat<-xmlValue(geoResult[['Latitude']])
            long<-xmlValue(geoResult[['Longitude']])
            myGeoTable<-rbind(myGeoTable,data.frame(address=myStreet,Y=lat,X=long,EID=NA))
          }
    }

When I try and reference myStreet$City and myStreet$Address, I receive an error

$ operator is invalid for atomic vectors

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:53:17+00:00Added an answer on May 12, 2026 at 2:53 pm

    If myStreets is data.frame then for loop takes each column of it. So first step takes Addres and Addres$City doesn’t make sense.

    You could change for condition to loop over rows:

    for (i in 1:nrow(myStreets))  {
       myStreet <- myStreets[i,]
       # rest is the same
    }
    

    To optimized your code you can also do something like:

    myGeoTable <- data.frame( address=myStreet$address, lat=NA_real_, long=NA_real_, EID=NA_real_)
    for (i in 1:nrow(myStreets))  {
      myStreet <- myStreets[i,] 
      requestUrl <- ...
      ...
      myGeoTable[i,2:4] <- c(lat,long,NA)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dataframe (14.5K rows by 15 columns) containing billing data from 2001
In R I am trying to delete rows within a dataframe (ants) which have
Have you ever seen any of there error messages? -- SQL Server 2000 Could
I have a dataframe, and I want to produce a table of summary statistics
I have a dataframe df.all and I'm plotting it in a bar plot with
I have a dataframe that I want to reshape; my reshape code: matchedlong <-
I have a dataframe with numeric entries like this one test <- data.frame(x =
I have a dataframe and would like to calculate the correlation (with Spearman, data
I have a dataframe in R with a vector of non-sequential numbers ( data$SiteID
I have the following dataframe ( df ) start end 1 14379 32094 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.