探索叢集
由於叢集分析一部分帶有質性判斷,因此具備探索叢集結果的工具非常重要。
在這個練習中,你會探索上一個練習中建立的資料框 lineup_k2_complete。
提醒:lineup_k2_complete 資料框包含 6v6 足球比賽開場時 12 位球員的 x 與 y 位置,你也已依下列參數加入叢集指派結果:
- 距離:Euclidean
- 叢集數(k):2
- 連結方式(linkage method):Complete
本練習屬於課程
R 的叢集分析
練習說明
- 使用 dplyr 的
count(),計算每個叢集中被指派的球員數量。 - 使用
ggplot(),繪製球員的位置,並依叢集指派上色。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Count the cluster assignments
count(lineup_k2_complete, ___)
# Plot the positions of the players and color them using their cluster
ggplot(lineup_k2_complete, aes(x = ___, y = ___, color = factor(___))) +
geom_point()