開始使用免費開始

依「yes」票比例排序

現在你已經把資料集依國家進行彙總,可以開始檢視資料,並回答一些有趣的問題。

例如,你也許會特別關心哪些國家最少投「yes」,或哪些國家最常投「yes」。

本練習屬於課程

案例研究:R 中的探索性資料分析

檢視課程

練習說明

  • 列印上一個練習建立的 by_country 資料集。
  • 使用 arrange()percent_yes 遞增排序各國家。
  • 以相同變數進行排序,但改為遞減順序。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# You have the votes summarized by country
by_country <- votes_processed %>%
  group_by(country) %>%
  summarize(total = n(),
            percent_yes = mean(vote == 1))

# Print the by_country dataset


# Sort in ascending order of percent_yes


# Now sort in descending order
編輯並執行程式碼