开始使用免费开始使用

层次聚类:绘制职业聚类图

您已经成功创建了探索本次层次聚类结果所需的各个部分。本练习中,您将利用具名分配向量 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))
编辑并运行代码