Session Ready
Exercise

Extracting mentions

In each sublist of the dataset of tweets, there is an element called "mentions_screen_name" (i.e. Twitter handles). This element contains either NULL if there was no mention in the tweet, or one or more screen names mentioned in the tweet. A way to detect a popular account from a list of tweets is to detect who are the most mentioned users in a specific tweet collection.

We'll first extract a vector of all mentions, and once we've got this new vector, we'll count the number of time each profile is mentioned. To do that, we'll build a new composed function, by combining table() (which counts the number of occurrences of each element in the vector), sort(), and tail().

purrr has been loaded for you, and rstudioconf is available in your dataset.

Instructions
100 XP
  • Build a function that is the combination of as_vector(), compact(), and flatten().

  • Create a function that takes two arguments: list and what. This function will run map( list, what ), and pass the result to flatten_to_vector.

  • Create six_most, a function that combines tail(), sort(), and table().

  • Run extractor() on rstudioconf, and pass the result to six_most().