Notes On Google Trend Data

By Sebastian Warnholz, 0 comments.

This article is archived because of a reason. The content can be outdated or in draft form. You are welcome to read it anyway.

Some notes on querying and reshaping data from Google trends. Most importantly your language in you Google account must be in English. The package relies on some keywords.

devtools::install_github("PMassicotte/gtrendsR")
library(gtrendsR)

usr <- ""  # alternatively store as options() or env.var
psw <- ""              # idem

gconnect(usr, psw)       # stores handle in environment

res <- gtrends(c("Pizza", "Pasta", "Italy"), geo = "IT")

Need some reshaping for using data on cities.

do.call(rbind, 
        lapply(res$cities, function(df) {
          df$query <- names(df)[[2]]
          names(df)[[2]] <- "count"
          df
        })
)