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_tags
yanswers_with_tags
enposts_with_tags
. - Añada una columna
year
a la tablaposts_with_tags
y, a continuación, cuente los mensajes portype
,year
ytag_name
.
Ejercicio interactivo práctico
Prueba este ejercicio completando 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 %>%
___