R
Package APIs
There are more streamlined ways to extract data from external sources. Let’s explore some R
package that provide wrapper for useful APIs to streamline data extraction and acquisition.
What is Google Trends? “Google Trends is a website by Google that analyzes the popularity of top search queries in Google Search across various regions and languages. The website uses graphs to compare the search volume of different queries over time.” - Wikipedia
gtrendsR
: An interface for retrieving and displaying the information returned online by Google Trends is provided. Trends (number of hits) over the time as well as geographic representation of the results can be displayed.trendyy
: a tidy wrapper to the gtrendsR
package.## Loading required package: trendyy
# Specify the search terms you're interested in.
my_search_terms <- c("Biden","trump")
# Download the term activity across a specific period using the Google Trends API
trends <- trendy(search_terms = my_search_terms,
from = "2020-09-01",to="2020-09-30")
Clean and examine the data.
# Trends sends you back a lot of data. Use trendyy's helper functions to get
# what we want: search term interest over time.
dat_trends <- get_interest(trends)
dat_trends
Visualize.