This is an R Markdown document giving a few examples of using Google Trends https://www.google.com/trends/ data from within R using the GTrendsR package.

Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit HTML button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

Install the GTrends R package

# install.packages("gtrendsR")

Check that the packages are working

library(gtrendsR)

Sports Example

res <- gtrends(c("nba", "nfl"), geo = c("US", "US"))
plot(res)

Cars Example

car_trend <- gtrends(c("bmw", "audi", "porche"))
## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'
plot(car_trend)

Wine Example

query <- c("wine", "beer", "soda")
wine_data <- gtrends(query)
## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'
plot(wine_data)

Job Titles Example

query <- c("Data Scientist", "Data Hacker", "Data Analyst")
job_data <- gtrends(query)
## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'
plot(job_data)

Oil and Gas Prices Example

query <- c("Oil", "Gas", "Petroleum")
oil_data <- gtrends(query)
## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'
plot(oil_data)

Bitcoin Example

query <- c("bitcoin")
crypto_data <- gtrends(query)
## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'

## Warning in is.na(object): is.na() applied to non-(list or vector) of type
## 'NULL'
plot(crypto_data)