Začněte nyníZačněte zdarma

Spojování a počítání příspěvků se štítky

Tabulky, které jsi vytvořil/a v předchozím cvičení, jsou přednahrány jako questions_with_tags a answers_with_tags. Nejdřív tyto tabulky zkombinuješ do jedné tabulky s názvem posts_with_tags. Jakmile máš data pohromadě, můžeš je obohatit o datovou proměnnou pomocí balíčku lubridate, který je již přednahrán.

questions_with_tags <- questions %>%
  inner_join(question_tags, by = c("id" = "question_id")) %>%
  inner_join(tags, by = c("tag_id" = "id"))
answers_with_tags <- answers %>%
  inner_join(question_tags, by = "question_id") %>%
  inner_join(tags, by = c("tag_id" = "id"))

Toto cvičení je součástí kurzu

Joining Data with dplyr

Zobrazit kurz

Pokyny k cvičení

  • Spoj tabulky questions_with_tags a answers_with_tags do tabulky posts_with_tags.
  • Přidej do tabulky posts_with_tags sloupec year a pak spočítej příspěvky podle type, year a tag_name.

Interaktivní cvičení na vyzkoušení si v praxi

Vyzkoušejte si toto cvičení dokončením tohoto ukázkového kódu.

# Combine the two tables into posts_with_tags
posts_with_tags <- ___(questions_with_tags %>% mutate(type = "question"),
                              answers_with_tags %>% mutate(type = "answer"))

# Add a year column, then count by type, year, and tag_name
posts_with_tags %>%
  ___
Upravit a spustit kód