可视化归一化后的流行度变化
您已经选取了几个名字,并将每个名字相对于其峰值进行归一化,计算为其峰值的比例。这是一种对名字进行"归一化"的方法,关注的是每个名字内部的相对变化,而不是名字的总体流行度。
在本练习中,您将可视化每个名字的归一化流行度。上一练习中的结果 names_normalized 已为您提供。
names_normalized <- babynames %>%
group_by(name) %>%
mutate(name_total = sum(number),
name_max = max(number)) %>%
ungroup() %>%
mutate(fraction_max = number / name_max)
本练习是课程的一部分
使用 dplyr 进行数据处理
练习说明
- 过滤
names_normalized表,仅保留三个名字:Steven、Thomas和Matthew。 - 基于
names_filtered创建折线图,按时间展示fraction_max的变化,并用name着色。
交互式实操练习
通过完成这段示例代码来试试这个练习。
names_filtered <- names_normalized %>%
# Filter for the names Steven, Thomas, and Matthew
___
# Visualize the names in names_filtered over time
___