From the course: Creating Maps with R

Unlock the full course today

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

Solution: Geolocate all US state capitol buildings

Solution: Geolocate all US state capitol buildings

From the course: Creating Maps with R

Solution: Geolocate all US state capitol buildings

(upbeat music) - Okay, let's get started on this challenge of geocoding the state capitols of the USA. So I'm going to load all of the packages and we need to read in our data file. So I'll create a variable name, capital buildings, and we'll use the function read underscore excel. We'll open a quotation mark and I'll press the tab key so I can see the file tree and our select our xlsx file and let's run back out. Now let's print this to the console so we can see what the data set looks like. And we've got three columns, capitol name, address capitol, that's the street address, and we have state. So we've got all the information we need in theory to geocode this. So, let's create a new object called capitol buildings geocoded, and we'll take our existing tibble, capitol buildings, and we'll pipe it into the function geocode. Now we need to provide the components of the address that we have. So the street argument…

Contents