Łączenie i zliczanie postów z tagami
Tabele utworzone w poprzednim ćwiczeniu zostały wstępnie załadowane jako questions_with_tags i answers_with_tags. Na początku połącz je w jedną tabelę o nazwie posts_with_tags. Po scaleniu danych możesz wzbogacić tabelę o dodatkowe informacje, tworząc zmienną daty za pomocą pakietu lubridate, który jest już załadowany.
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"))
To ćwiczenie jest częścią kursu
Łączenie danych z dplyr
Instrukcje do ćwiczenia
- Połącz tabele
questions_with_tagsianswers_with_tagsw tabelęposts_with_tags. - Dodaj kolumnę
yeardo tabeliposts_with_tags, a następnie zlicz posty wedługtype,yearitag_name.
Interaktywne ćwiczenie praktyczne
Spróbuj tego ćwiczenia, uzupełniając ten przykładowy kod.
# 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 %>%
___