ComenzarEmpieza gratis

Unir y contar publicaciones con etiquetas

Las tablas que creaste en el ejercicio anterior se han precargado como questions_with_tags y answers_with_tags. Primero, combina estas tablas en una sola llamada posts_with_tags. Una vez que la información esté unificada en una sola tabla, podrás añadir más datos creando una variable de fecha con el paquete lubridate, que ya está precargado.

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

Uniones de datos con dplyr

Ver curso

Instrucciones del ejercicio

  • Combina las tablas questions_with_tags y answers_with_tags en posts_with_tags.
  • Añade una columna year a la tabla posts_with_tags y luego cuenta publicaciones por type, year y tag_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 %>%
  ___
Editar y ejecutar código