Visualizing questions and answers in tags
In the last exercise, you modified the posts_with_tags
table to add a year
column, and aggregated by type
, year
, and tag_name
. The modified table has been preloaded for you as by_type_year_tag
, and has one observation for each type (question/answer), year, and tag. Let's create a plot to examine the information that the table contains about questions and answers for the dplyr
and ggplot2
tags. The ggplot2
package has been preloaded for you.
by_type_year_tag <- posts_with_tags %>%
mutate(year = year(creation_date)) %>%
count(type, year, tag_name)
This exercise is part of the course
Joining Data with dplyr
Exercise instructions
- Filter the
by_type_year_tag
table for the dplyr and ggplot2 tags. - Create a line plot with that filtered table that plots the frequency (
n
) over time, colored by question/answer and faceted by tag.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Filter for the dplyr and ggplot2 tag names
by_type_year_tag_filtered <- by_type_year_tag %>%
filter(___)
# Create a line plot faceted by the tag name
ggplot(by_type_year_tag_filtered, aes(___, ___, color = ___)) +
geom_line() +
facet_wrap(~ tag_name)