重新排序图形
上一题中您绘制的图表可以阅读,但如果能按顺序排列,就能一眼看懂。让我们用一些 forcats 函数把图表调整为从左到右按平均有用性降序排列。
数据集 usefulness_by_platform 已为您加载。
本练习是课程的一部分
Tidyverse 中的分类数据
练习说明
- 按
avg_usefulness对图中的learning_platform排序,使其从左到右按有用性从高到低排列。
交互式实操练习
通过完成这段示例代码来试试这个练习。
usefulness_by_platform %>%
# Reorder learning_platform by avg_usefulness
mutate(learning_platform = ___(___, ___)) %>%
# Reverse the order of learning_platform
mutate(learning_platform = ___) %>%
ggplot(aes(x = learning_platform, y = avg_usefulness)) +
geom_point() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(x = "Learning Platform", y = "Percent finding at least somewhat useful") +
scale_y_continuous(labels = scales::percent_format())