gtrendR

gtrendR: Analyze and Visualize data from the Google Trends for Health API with R

Features

This package currently focuses on analyzing "spikes" (or other increases) in search volumes from Google Trends occurring after some known event ("interruption"). An increase in searches following an event may indicate that the event spurred increased public interest in a health topic or behavior. For example, past studies have used increases in searches following a given date to provide evidence that Charlie Sheen's HIV announcement increased searches for HIV testing, that the Netflix show "13 Reasons Why" increased searches for committing suicide, and that the #MeToo movement increased searches for sexual harassment training. Now you can do the same sort of analyses with even beginner-level expertise in R! Specifically, this package allows users to:

  • Perform ARIMA-based interrupted time series analysis
  • Analyze and visualize the difference between actual and expected searches
  • Compare search volumes before and after an interruption
  • Conduct ARIMA analyses analyses over several states
  • Compare search volume growth among several search terms
  • Easily compute estimates of the absolute counts of Google searches using Comscore

Be well on your way to publication-worthy results in just 10 minutes!

  1. Set your file structure for your project. If you want to follow along with my examples, you should set it up like this:
  root
  ├───code
  ├───input
  │   └───individual
  ├───output
  └───temp
  1. Pull your data from Google Trends using gtrendspy.
  2. Install the gtrendR package for R.
  3. Decide what figure you want to make first by clicking on one of the graphs below.
  4. Follow the instructions on the page. Typically, there's an initial step to process your data into the correct format, and then you can skip to the function that generates the figure you want.
  5. Repeat for as many functions as you'd like to create a nice "data dashboard"!

Click on any of the following graph types to see how you can make one using your own data.

line_plot

Line Plot

arima_plot

ARIMA Plot

arima_ciplot

ARIMA Confidence Intervals

state_pct_change

Percent Change by State

state_arima_spaghetti

Spaghetti Plot by State

state_arima_pctdiff

Percent Difference by State

multiterm_barplot

Percent Change by Term

multiterm_spaghetti

Spaghetti Plot for Several Terms

Disclaimer

This project is a work-in-progress. It works in some cases but may not work in many others (and may not be flexible enough for some users), and some extra code exists for functions that are not yet operational. Most things are not properly documented, and you may need to refer to the source code. This program has only been tested in Windows 10.

Citation

If you find this package useful, please consider citing me in your work.

Caputi TL. 2020. gtrendspy and gtrendR: Packages for analyzing Google Trends Data.