课程: Data Visualization in R with ggplot2

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Zooming in on California

Zooming in on California

- [Instructor] Next, I'd like to zoom in on California to get some more detail on the school locations in that state. The first thing I need to do is create new map data that only includes California. Since we're zooming into a single state, I'd like to get a county map this time, but only for California. I can do this by calling map_data with those arguments. My new dataset is going to be called california, and I'm going to fill it with the map_data function, saying I would like a county-level map for the region of California. And now let's re-plot the map using only this California data. I'm just going to copy my code from before, paste it down here, and instead of having states as the data I'm sending to ggplot, I'm going to change this to california. And as you can see here, I have fixed the map underneath the data, but I still have the points for all of the schools in the Continental US. Clearly, I need to fix that as well. I can narrow down my dataset using dplyr's filter verb…

内容