ggplot2로 점-밀도 지도 만들기
이번 강의의 마지막 연습 문제에서는, 지금까지 수집하고 생성한 데이터셋을 ggplot2로 점-밀도 지도에 통합해 보겠습니다. geom_sf()로 생성한 점과 보조 데이터셋을 함께 그린 뒤, 지도 요소를 더해 완성도 있는 지도 산출물을 만들어 보세요.
이 연습은 강의의 일부입니다
R로 분석하는 미국 인구조사 데이터
연습 안내
geom_sf()를 사용해 simple features 객체를 그리세요.- 앞에서 만든 객체를 올바르게 지정하여 수계(water)와 도로(roads) 피처를 그리세요.
labs()의caption매개변수를 사용해 지도에 정보가 담긴 캡션을 추가하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Plot your datasets and give your map an informative caption
___() +
___(___ = dc_boundary, color = NA, fill = "white") +
___(data = dc_dots, ___(color = group, fill = group), size = 0.1) +
___(data = ___, color = "lightblue", fill = "lightblue") +
___(data = ___, color = "grey") +
coord_sf(crs = 26918, datum = NA) +
scale_color_brewer(palette = "Set1", guide = FALSE) +
scale_fill_brewer(___ = "Set1") +
labs(title = "The racial geography of Washington, DC",
subtitle = "2010 decennial U.S. Census",
fill = "",
___ = "1 dot = approximately 100 people.\nData acquired with the R tidycensus and tigris packages.")