依斜率排序
既然你已經篩選出趨勢很可能不是隨機造成的國家,接下來或許會想找出「同意」票比例隨時間變化最快的國家。也就是要找出斜率最高與最低者;對應到 estimate 欄。
本練習屬於課程
案例研究:R 中的探索性資料分析
練習說明
- 使用
arrange()與desc(),將篩選後的國家排序,找出「同意」比例隨時間增加最快的國家。 - 使用
arrange()排序,找出「同意」比例隨時間減少最快的國家。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Filter by adjusted p-values
filtered_countries <- country_coefficients %>%
filter(term == "year") %>%
mutate(p.adjusted = p.adjust(p.value)) %>%
filter(p.adjusted < .05)
# Sort for the countries increasing most quickly
# Sort for the countries decreasing most quickly