Encuadernación y recuento de entradas con etiquetas
Las tablas que creó en el ejercicio anterior se han cargado previamente como questions_with_tags y answers_with_tags. En primer lugar, querrá combinar estas tablas en una única tabla llamada posts_with_tags. Una vez consolidada la información en una única tabla, puede añadir más información creando una variable de fecha utilizando el paquete lubridate, que se ha cargado previamente para usted.
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"))
Este ejercicio forma parte del curso
Unir datos con dplyr
Instrucciones del ejercicio
- Combine las tablas
questions_with_tagsyanswers_with_tagsenposts_with_tags. - Añada una columna
yeara la tablaposts_with_tagsy, a continuación, cuente los mensajes portype,yearytag_name.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# 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 %>%
___