Analyse Google Trends Search Data in R using {gtrendsR}

As much as Google is popular for searching information on the web, Google can also provide information (meta) about those searches. Google Search Insights can be extremely helpful in Marketing Analytics, Market Research, Understanding Customer Demands, Trends and so on. While usual Market Researches or someone interested in Google Search Information would go to Google Trends website, Being a programmer you can extract the same information programmatically to use in your Data Science Workflow or to set up an Automation.

In this video, We go through how to use the R package {gtrendsR} to analyse Google Trends Search Data.

Youtube: https://www.youtube.com/watch?v=xbLJNARUyT0

Code

library(gtrendsR)
library(tidyverse)


res <- gtrends(c("zoom", "slack"))

iot <- res$interest_over_time

iot2020 <- iot %>% 
  filter(date > as.Date("2020-01-01"))

iot2020 %>% 
  ggplot() + geom_line(aes(x = date,
                           y = hits,
                           color = keyword)) +
  theme_minimal() +
  labs(title = "Zoom vs Slack - in 2020",
       subtitle = "Google Trends Report",
       caption = "Courtesy: gtrendsR package")
library(gtrendsR)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)


res <- gtrends(c("zoom", "slack"))

iot <- res$interest_over_time

iot2020 <- iot %>% 
  filter(date > as.Date("2020-01-01"))
## Warning in mask$eval_all_filter(dots, env_filter): Incompatible methods
## ("Ops.POSIXt", "Ops.Date") for ">"
iot2020 %>% 
  ggplot() + geom_line(aes(x = date,
                           y = hits,
                           color = keyword)) +
  theme_minimal() +
  labs(title = "Zoom vs Slack - in 2020",
       subtitle = "Google Trends Report",
       caption = "Courtesy: gtrendsR package")

Please raise a github issue if you find any difficulties and let me know your feedback if you have any comments!

 
comments powered by Disqus