The goal of this assignment is to compare and analyze data on the search terms "Trump," "Kamala Harris," and "Election" using two methods: the Google Trends website and the gtrendsR
package in R. The analysis involves reviewing the data collected in terms of dates, intervals, and identifying differences between the two methods.
To begin the analysis, I visited the Google Trends website and input the search terms "Trump," "Kamala Harris," and "Election." I set the time range to 2020-01-01 to 2023-12-31 and chose the global region to maximize data collection.
After entering the terms, Google Trends generated a comparative interest graph showing the relative popularity of each term over time. I downloaded the data by clicking the download icon, which saved the information as a .csv
file.
a. Dates: The data from the Google Trends website is broken down by weeks. Each row represents the relative search interest for each search term during a given week, starting from January 2020 to December 2023.
b. Intervals: The website provides weekly data intervals. The search interest is given as an index (0-100), where 100 represents peak popularity.
c. Observations: The data shows peaks in search interest around significant political events, such as the 2020 U.S. Presidential Election and key announcements.
I used the gtrendsR
package in R to collect data for the same search terms. Below is the R code I used:
# Load necessary libraries
library(gtrendsR)
# Define the search terms and time range
terms <- c("Trump", "Kamala Harris", "Election")
time_range <- "2020-01-01 2023-12-31"
# Fetch Google Trends data
trends_data <- gtrends(terms, time = time_range)
# View the data
head(trends_data$interest_over_time)
# Save the data to a CSV file
write.csv(trends_data$interest_over_time, "gtrends_data.csv")
The gtrends()
function fetched data for the search terms, also broken down by weekly intervals.
a. Dates: The data from gtrendsR
is also broken down by weekly intervals, covering January 2020 to December 2023.
b. Intervals: The data intervals collected via gtrendsR
are weekly, similar to the website data.
c. Observations: The trends observed align with those from the Google Trends website, showing peaks in interest for the search terms during key political events.
a. Ease of Use: The Google Trends website is intuitive and user-friendly, whereas the gtrendsR
package offers more flexibility for automated data collection and analysis.
b. Customization and Data Granularity: The Google Trends website offers more customization options, while gtrendsR
is slightly more limited but provides weekly data intervals.
c. Data Format: Data from the website is pre-formatted in a .csv
file, while gtrendsR
data is stored as a data frame in R for further manipulation.
Flexibility: The gtrendsR
package offers more automation and flexibility, while the Google Trends website is ideal for quick visualizations and smaller-scale projects.
Both methods are effective for collecting Google Trends data, but each has its strengths depending on the user's familiarity with programming and the scale of data analysis required.