LoslegenKostenlos loslegen

California Colleges

Now it is your turn to map all of the colleges in a state. In this exercise, we'll apply our example of mapping Maine's colleges to California's colleges. The first step is to set up your data by filtering the ipeds data frame to include only colleges in California. For reference, you will find how we accomplished this with the colleges in Maine below.

maine_colleges <- 
    ipeds %>% 
        filter(state == "ME")

maine_colleges

# A tibble: 21 x 5
                     name       lng      lat state sector_label
                    <chr>     <dbl>    <dbl> <chr>        <chr>
1           Bates College -70.20333 44.10530    ME      Private
2         Bowdoin College -69.96524 43.90690    ME      Private

Diese Übung ist Teil des Kurses

Interactive Maps with leaflet in R

Kurs anzeigen

Anleitung zur Übung

  • Create a data frame called ca with data on only colleges in California.
  • Use addMarkers() to plot all of the colleges in ca on map.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Create a dataframe called `ca` with data on only colleges in California
___ <- ipeds %>%
        filter(state == "___")

# Use `addMarkers` to plot all of the colleges in `ca` on the `m` leaflet map
map %>%
    ___(lng = ___, lat = ___)
Code bearbeiten und ausführen