開始使用免費開始

以標籤視覺化問題與解答

在上一個練習中,你修改了 posts_with_tags 資料表,新增了 year 欄位,並依 typeyeartag_name 進行彙總。已替你預先載入修改後的資料表 by_type_year_tag,其中每一筆觀測都對應到一種型別(question/answer)、一年份與一個標籤。現在來建立一張圖,觀察此資料表中關於 dplyrggplot2 標籤的問題與解答資訊。已替你預先載入 ggplot2 套件。

by_type_year_tag <- posts_with_tags %>%
  mutate(year = year(creation_date)) %>%
  count(type, year, tag_name)

本練習屬於課程

使用 dplyr 進行資料表連接

檢視課程

練習說明

  • by_type_year_tag 資料表篩選出 dplyr 與 ggplot2 這兩個標籤。
  • 使用篩選後的資料建立折線圖,將時間上的頻率(n)畫出來,並以問題/解答作為顏色區分,依標籤分面。

動手互動練習

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

# Filter for the dplyr and ggplot2 tag names 
by_type_year_tag_filtered <- by_type_year_tag %>%
  filter(___)

# Create a line plot faceted by the tag name 
ggplot(by_type_year_tag_filtered, aes(___, ___, color = ___)) +
  geom_line() +
  facet_wrap(~ tag_name)
編輯並執行程式碼