開始使用免費開始

階層式分群:繪製職業分群圖

你已經成功建立了探索此階層式分群結果所需的所有部分。這個練習中,你會運用具名指定向量 cut_oes 和整齊資料框 gathered_oes 來分析分群結果。

本練習屬於課程

R 的叢集分析

檢視課程

練習說明

  • 透過使用 sort()cut_oes 向量排序,查看各職業被分配到的群集。
  • 使用 ggplot2 繪製各職業逐年的平均收入,並依職業所屬的群集為折線著色。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# View the clustering assignments by sorting the cluster assignment vector
sort(___)

# Plot the relationship between mean_salary and year and color the lines by the assigned cluster
ggplot(___, aes(x = ___, y = ___, color = factor(___))) + 
    geom_line(aes(group = occupation))
編輯並執行程式碼