开始使用免费开始使用

探索聚类

由于聚类分析始终包含定性判断,拥有能够探索聚类结果的工具就格外重要。

在本练习中,您将探索上一个练习中创建的数据框 lineup_k2_complete

提醒:数据框 lineup_k2_complete 包含一场 6v6 足球比赛开场时 12 名球员的 x 和 y 位置,并基于以下参数添加了聚类分配结果:

  • 距离:Euclidean(欧氏距离)
  • 聚类数(k):2
  • 连接方法: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()
编辑并运行代码