Reputation: 12550
I have a map of the USA, ready to go:
mygggmap <- get_map(location = "United States", zoom = 4)
g <- ggmap(myggmap)
The next step is to plot some major cities.
I understand I can create a layer to plot my major cities by their longitude and latitude, something like:
g <- g + geom_density2d(data = citydata, aes(x = lon, y = lat))
but I am wondering if there is a way to plot by the actual name, city and state? Since ggmap is layered over the Google Map API, this should be possible, correct?
Upvotes: 1
Views: 4040
Reputation: 484
If you want to explore further, you could also supplement your original data with data from the zipcode
package. It has zip codes for about 43K US cities. For more information, you can check out the link http://www.r-bloggers.com/my-first-r-package-zipcode
Upvotes: 1
Reputation: 12550
I found the answer. It is simple. Use the geocode function:
geocode("SEATTLE")
returns
lon lat
-122.3321 47.60621
Thanks for the support everyone. Even though I just got a 'tumbleweed' badge.
Upvotes: 6