Wednesday, June 12, 2013

Introducing GTrendsR

In a paper, to be soon published in Conservation Biology and entitle Googling trends in conservation biology, we developed a package named GTrendsR that provides an interface for retrieving and displaying the information returned online by Google Trends in R. Whereas the package is still under development, I'm pleased to present an early overview of GTrendsR. You can download the PDF of the appendix of our paper which presents a detailed tutorial on how to use the package.

This is the first package I develop in R and I probably made some mistakes. So feel free to contact me with suggestions.

To download the article published in Conservation Biology

UPDATE (10/24/2013)

The package is now available for download on bitbucket.

install_bitbucket("GTrendsR", "persican")



Just another R blog has beed added to r-bloggers!

In closing, I am very pleased to announce that this blog has been added to r-bloggers. For those who are new to this blog, I invite you to take a look to this page.


  1. Hi Phil. Thanks for the information. I was actually exploring your package a few weeks back. I had trouble getting your twitter/myspace example to work. I asked about it on stackoverflow... ...but never got an answer. Perhaps you can help?... Sorry I can not help you with your problem,... and to introduce a new one.

    1. Hi Guy (perhaps you speak french?)

      Anyway, have you tried to download the package gTrendsR on my blog? If so, where are you having issue?


    2. ahh no, sorry I confused your package for rGtrends. my bad. i have had a bash at running your example. first time I got error message when trying to pull the data...

      > data = gTrends(ch, geo = location, query = query)
      Error in data.frame(Timespan = temp, SreachTerms = ss) :
      arguments imply differing number of rows: 0, 1

      i also got a email from google notifying me of suspicious sign in that was prevented. second time it worked. third time i got an error that i had hit the query limit.

    3. Ill try to fix it asap!

  2. This comment has been removed by the author.

  3. Hi phil,
    I am Rajkumar, I am an electronics engineer now I am pursuing my MBA. I want to do a project on analyzing consumer behavior towards a product over internet for that I am using Google trends. I read an article which is posted by you on june 12, 2013 about GTrendsR you stated some problem on it.

    I try to connect the GTrendsR using the command install.packages("GTrends") and the command which you given here but I won't get the any results. If you don't mind can you give some suggestion to me that will help to proceed my project.

    1. hi Raj. The package is now available!

  4. I tried today to install the package and it returned :
    Warning message:
    package ‘GTrends’ is not available (for R version 3.0.2)

    1. library(devtools)
      install_bitbucket("GTrendsR", "persican")

  5. Hi Phil,

    I tried to reproduce your example but it gives me

    "Not enough search volume to show results."

    I then tried other more famous terms, like twitter or facebook, but I got the same reply.

    1. After your message, I downloaded the latest R (3.0.2, 64 bit) and re-installed everything. This time everything goes ok , except for the last line which gives me the following error:

      > data = gTrends(ch, geo = "all", query = query)

      Error in ans[[index.subreg]] : attempt to select less than one element

    2. Hi Phil

      I managed to solve the problem (at least when using a location different from "Worldwide": it was not your package, but my email the source of the problem. For some reasons, when using my standard email, Google allowed me to download the csv files manually but not automatically. I suppose this may be some sort of block imposed by Google, probably because I was downloading too many csv files. Therefore, I have created a new account and everything works fine.

      The only problem left is when the location is Worldwide, so that the "geo" location is empty.

      If you manage to find a solution for that, please let me know it.

      Thanks, Janet

  6. I have below problem after logining successful, can you given me some suggestions. Thank you!
    > data <- gTrends(ch, geo = "CA", query = "NFL")
    [1] "Not enough search volume to show results."

  7. Hi, Phil. I also get the message "Not enough search volume to show results.". I'm using R version 3.0.2 (2013-09-25), 64bit on Windows. Thanks.