Get startedGet started for free

Twitter trends

1. Twitter trends

Twitter trends can be used for dynamic social media analysis.

2. Lesson Overview

In this lesson, we will understand the concept of twitter trends and learn how to extract trending topics. We will also explore how to use the extracted trends effectively to participate in popular conversations and increase engagement.

3. What is a twitter trend?

Twitter trends are keywords, events, or topics that are currently popular and help us discover the hottest emerging discussions on Twitter. Some trends include a hashtag to relate tweets to a topic so people can search and follow the conversation. Location trends identify popular topics in a specific location.

4. Leveraging the power of twitter trends

By blending its marketing messages with a trending topic, a business will add value by resonating with a wider audience and increase engagement. So, it is important to find the right trending topic that fits your brand. For example, a travel portal can tweet around the trend "hashtagTravelTuesday".

5. Extract worldwide trends

We will use the get_trends() function from rtweet to extract all topics currently trending worldwide on twitter. Since we have not provided any argument, the function extracts all the current trending topics. As you can see from the output, the worldwide trending topics are in different languages. It will be more meaningful to extract trends around a specific region to focus on twitter audience in that region.

6. Locations with current trends

To identify the geographical locations where trending topics are currently available, we use the trends_available() function. We can see a list of cities or towns and their country names displayed here. We can extract what is trending in a specific city or a country from this list.

7. Trending topics by country

Let us extract what is trending in the United States. We use the get_trends() function again but also include the argument "United States".

8. Trending topics by country

Upon viewing the output, we can see that "hashtagRockHall2020" is one of the current trending topics across the US. A music video company can position its promotions using tweets including this trending topic.

9. Trending topics by city

To promote a product in a specific city, we can find what is trending in that city and attach our tweets around a relevant trend. Let's find out the topics that are trending in New York. We use get_trends() with the argument "New York".

10. Trending topics by city

Let's view the column trend which has the list of trending topics. We can see that "LeBron", referring to the famous NBA player Lebron James, is trending in New York. A company promoting basketball merchandise in New York could leverage this trend by placing tweets around this trend.

11. Most tweeted trends

The data frame extracted using get_trends() has a column called tweet_volume which stores the count of tweets for the trending topics. The data for tweet_volume is available for some trends only. It will be interesting to see which trends are most tweeted. Let us extract tweet volumes for trends from "New York".

12. Most tweeted trends

We use summarize() and group_by() functions to group trends by tweet volumes. To group data in the data frame gt_city, group_by() takes the column trend as input. summarize() creates one row per group and it takes the mean() of tweet_volume as input.

13. Most tweeted trends

The output displays aggregated trends and tweet volumes.

14. Most tweeted trends

Next, we reorder the trends on decreasing order of tweet volumes using desc() within the arrange() function.

15. Most tweeted trends

From the output, we can see that "Columbus Day" is one of the trends with a high tweet volume. This trend is associated with Columbus Day, a national holiday in the US that celebrates the arrival of Columbus in the Americas. A travel company can promote holiday packages around this trend.

16. Let's practice!

We learned about twitter trends and using them to engage with a wider or region-specific audience. Let's practice!