课程: Data Visualization in R with ggplot2
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Adding city names
- [Instructor] 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. Let's geocode them and plot them on the map. I'm going to begin by creating a vector that includes the names of those cities We'll call it city_names and we'll put in Los Angeles, San Diego, San Jose, San Francisco, Fresno, and Sacramento. Then, I'll use the geocode function to create a vector containing the coordinates of each city. I'm going to create locations as my new object, and I'm going to fill it using geocode on city_names. That will send those off to Google to be geocoded and give me the latitude and longitude back. Now, let's put all this together in a cities tibble. I'm going to have the name in that tibble coming from the city_names vector, I'm going to have latitude coming from the latitude vector in locations. and then the same thing for longitude…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。