Sometime earlier last year, I started to help Philippe Massicotte with his gtrendsR package—which was then still "hiding" in relatively obscurity on BitBucket. I was able to assist with a few things related to internal data handling as well as package setup and package builds–but the package is really largely Philippe’s. But then we both got busy, and it wasn’t until this summer at the excellent useR! 2015 conference that we met and concluded that we really should finish the package. And we both remained busy…
Lo and behold, following a recent transfer to this GitHub repository, we finalised a number of outstanding issues. And Philippe was even kind enough to label me a co-author. And now the package is on CRAN as of yesterday. So
install.packages("gtrendsR") away and enjoy!
Here is a quiick demo:
## load the package, and if options() are set appropriately, connect ## alternatively, also run gconnect("someuser", "somepassword") library(gtrendsR) ## using the default connection, run a query for three terms res <- gtrends(c("nhl", "nba", "nfl")) ## plot (in default mode) as time series plot(res) ## plot via googeVis to browser ## highlighting regions (probably countries) and cities plot(res, type = "region") plot(res, type = "cities")
The time series (default) plot for this query came out as follows a couple of days ago:
One really nice feature of the package is the rather rich data structure. The result set for the query above is actually stored in the package and can be accessed. It contains a number of components:
R> data(sport_trend) R> names(sport_trend)  "query" "meta" "trend" "regions" "topmetros"  "cities" "searches" "rising" "headers" R>
So not only can one look at trends, but also at regions, metropolitan areas, and cities — even plot this easily via package googleVis which is accessed via options in the default plot method. Furthermore, related searches and rising queries may give leads to dynamics within the search.
Please use the standard GitHub issue system for bug reports, suggestions and alike.