gtrends 1.3.0 now on CRAN: Google Trends in R
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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) [1] "query" "meta" "trend" "regions" "topmetros" [6] "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.
This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.