Get startedGet started for free

Summarizing user types

Since you can use the count() wrapper, why bother counting rows in a group as part of a grouped summary? Sometimes you want a more detailed summary, and knowing how to compute a count as part of a grouped summary that mixes numeric and categorical summaries can come in handy.

This exercise is part of the course

Introduction to Text Analysis in R

View Course

Exercise instructions

  • Group twitter_data by whether or not a user is verified.
  • Compute the average number of followers for each type of user. Call this new column avg_followers.
  • Count the number of verified and non-verified users. For consistency, call this new column n.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

library(tidyverse)

twitter_data %>% 
  # Group by whether or not a user is verified
  ___(___) %>% 
  summarize(
    # Compute the average number of followers
    ___ = ___,
    # Count the number of users in each category
    ___ = ___
  )
Edit and Run Code