From the course: Data Visualization in R with ggplot2 (2018)

Unlock the full course today

Join today to access over 24,600 courses taught by industry experts.

Adding city names

Adding city names

- [Instructor] Once again, if you need to catch up, you can load the start file from the exercise files folder for this video. That brings us to the point that you see here, a map of California showing the schools in that state by institutional control and undergraduate population. As I look at this map, it's apparent that most of these schools are located in major population centers. I know the names of the six largest cities in California, but I'm not quite sure where they're located on the map. Let's geocode them and then plot them on the map. I'm going to begin by creating a vector of the city names. We'll call it city_names and we'll fill it with character strings containing the names of those cities. Los Angeles, San Diego, San Francisco, San Jose, Fresno, and Sacramento. Then the next thing I would like to do is use the geocode function to create a vector containing the coordinates of each city. We'll call that locations and we'll populate it by applying the geocode function to…

Contents