A very nice new update to the gtrendsR package by Philippe and myself is now avilable via CRAN. I had only blogged about the initial 1.3.0 release, and we have added a whole slew of new features and fixes. Philippe rewrote a lot of the parsing to make it more robust to different encodings, and to add other features. So in no particular order, we can now sub-group by regions more finely, withstand various misfeatures in returned data sets, generally do better on connections, and more --- and also allow for intra-day, daily and weekly queries!
That last part is pretty fun. Here is the code I ran last Saturday to look at the query for Donald Drumpf, a name brought to us via a beautiful John Oliver episode worth watching which ran about nine days ago. So last Saturday, when we were still within the seven day window, I ran
library(gtrendsR) dp <- gtrends("Donald Drumpf", res="7d") plot(dp) + ggplot2::ggtitle("The Drumpf") + ggplot2::theme(legend.position="none")
which resulted in the following chart
which highlights another nice feature: the ggplot2 object created by the plotting function is returned, so we can locally modify and tune it. Here we set a title and suppress the default legend.
As I had not blogged about the interim bug-fix releases 1.3.1 and 1.3.2, here is the set of NEWS entries for the last three releases:
A ggplot2 object can now be returned for further customization.
plot(gtrends("NHL")) + ggtitle("NHL trend") + theme(legend.position="none")
Support for hourly and daily data (#67). For example, it is now possible to have hourly data for the last seven days with
gtrends("nhl", geo = "CA", res = "7d"). Use
?gtrendsfor more information about the time resolution supported by the package.
Support for categorties (#46). Ex.:
gtrends("NHL", geo = "US", cat = "0-20")will search only in the sport category.
Some countries (ex: Hong Kong) were missing from the list (#69).
Various typos and documentation work.
Added support for sub-countries (#25). Ex.:
gtrends("NHL", geo = "CA-QC")will return trends data for Québec province in Canada. The list of supported sub-countries can be obtained via
Data parsing should work for any data returned by Google Trends (i.e. countries independent).
Better support for queries using keywords in different languages (#50, #57). Ex.:
gtrends("蘋果", geo = "TW")
Now able to specify up to five countries (#53) via
gtrends("NHL", geo = c("CA", "US"))
Fixing issue #51 allowing UK-based queries via
geo = "GB"
Fixing issue #34 where connection verification was not done properly.
Now able to use more latin character in query. For example:
- Can now deal with data returned other than in English language.
Courtesy of CRANberries, there is also a diffstat report for the this release. As always, more detailed information is on the gtrendsR repo where questions, comments etc should go via the issue tickets system.
Edited 2016-03-08: Corrected code snipped and one grammar instance