그래픽 다듬기
아래 코드 청크는 국가별 행복 점수를 사회적 지원 지수와 비교해 인터랙티브한 플롯으로 나타냅니다. 점의 모양은 각 국가의 소득 분류를 나타냅니다.
happy %>%
plot_ly(x = ~social.support, y = ~happiness,
hoverinfo = "text",
text = ~paste("Country: ", country)) %>%
add_markers(symbol = ~income, symbols = c("circle-open", "square-open", "star-open", "x-thin-open"))
여러분의 작업은 hover 정보와 축 레이블을 다듬어, 독자가 정보를 더 쉽게 파악할 수 있도록 하는 것입니다.
plotly와 happy 데이터 세트는 이미 로드되어 있습니다.
이 연습은 강의의 일부입니다
R로 배우는 plotly 중급 인터랙티브 데이터 시각화
연습 안내
income그룹,happiness점수,social.support지수에 대한 hover 정보를 추가하세요.- hover 정보의 모든 수치형 변수는
round(<variable>, 2)를 사용해 소수점 둘째 자리까지 반올림하세요. - x축 레이블은
"Social support index", y축 레이블은"National happiness score"로 변경하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Complete the following code to polish the plot
happy %>%
plot_ly(x = ~social.support, y = ~happiness,
hoverinfo = "text",
text = ~paste("Country: ", country,
"
Income: ", ___,
"
Happiness: ", ___,
"
Social support: ", ___)) %>%
add_markers(symbol = ~income,
symbols = c("circle-open", "square-open", "star-open", "x-thin-open")) %>%
layout(xaxis = ___,
yaxis = ___)