ComenzarEmpieza gratis

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

Ver curso

Instrucciones del ejercicio

  • Combine las tablas questions_with_tags y answers_with_tags en posts_with_tags.
  • Añada una columna year a la tabla posts_with_tags y, a continuación, cuente los mensajes por type, year y tag_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 %>%
  ___
Editar y ejecutar código