ภาพรวมบทที่ 2

Interactive Maps with leaflet in R

Rich Majerus

Vice President of Strategy & Planning, Queens University of Charlotte

ทบทวนจากบทที่แล้ว

leaflet() %>% 
    addProviderTiles("CartoDB") %>% 
    addMarkers(lng = dc_hq$lon, lat = dc_hq$lat, popup = dc_hq$hq)

แผนที่สุดท้ายของบทที่ 1

Interactive Maps with leaflet in R

ปรับแต่งแผนที่พื้นฐาน

m <- m %>% 
    setView(lat = 50.881363, 
            lng = 4.717863,
            zoom = 5)

ตัวอย่าง clearBounds() ที่ 1

# Restore view based on 
# data displayed on map
m  %>%
    clearBounds()

ตัวอย่าง clearBounds() ที่ 2

Interactive Maps with leaflet in R

ปรับแต่งแผนที่พื้นฐาน

# Restore view based on 
# data displayed on map
m  %>%
    clearBounds()

ตัวอย่าง clearMarkers() ที่ 1

# Remove markers
m  %>%
    clearBounds() %>% 
    clearMarkers()

ตัวอย่าง clearMarkers() ที่ 2

Interactive Maps with leaflet in R

IPEDS

  • Integrated Postsecondary Education Data System (IPEDS)

  • บริหารโดย National Center for Education Statistics (NCES)

  • ข้อมูลจากสถาบันที่เข้าร่วมโปรแกรมให้ทุนการศึกษาของรัฐบาลกลาง

    • วิทยาลัย
    • มหาวิทยาลัย
    • สถาบันเทคนิคและอาชีวศึกษา
Interactive Maps with leaflet in R

ชุดข้อมูล IPEDS ของเรา

> glimpse(ipeds)
Observations: 3,146
Variables: 5
$ name         <chr> "A T Still University of Health Sciences",...
$ lng          <dbl> -92.58918, -99.70954, -83.52828, -93.29968, ...
$ lat          <dbl> 40.19365, 32.46915, 31.48189, 44.85621, 29.65008, ...
$ state        <chr> "MO", "TX", "GA", "MN", "FL", "CA", "CA", "CA",... 
$ sector_label <chr> "Private", "Private", "Public", "For-Profit", ...
Interactive Maps with leaflet in R

ชุดข้อมูล IPEDS ของเรา

ipeds %>% group_by(state) %>% count %>% arrange(desc(n))
# A tibble: 56 x 2
# Groups:   state [56]
   state     n
   <chr> <int>
 1    CA   286
 2    NY   239
 3    PA   164
 4    FL   160
 5    TX   157
Interactive Maps with leaflet in R

เป้าหมายของบทที่ 2

  • กรองข้อมูลเฉพาะวิทยาลัยในแคลิฟอร์เนีย
  • แสดงวิทยาลัยทั้งหมดในแคลิฟอร์เนียบนแผนที่
  • ใช้ circle markers แทนหมุด
  • กำหนดสีของ markers ตาม sector

วิทยาลัยในแคลิฟอร์เนียแยกตาม sector

Interactive Maps with leaflet in R

มาฝึกกันเถอะ!

Interactive Maps with leaflet in R

Preparing Video For Download...