getGTrends           package:RGoogleTrends           R Documentation

_G_e_t _G_o_o_g_l_e _T_r_e_n_d_s _D_a_t_a _f_o_r _a _q_u_e_r_y

_D_e_s_c_r_i_p_t_i_o_n:

     This function fetches the Google Trends data for a particular
     topic. This data provides information about the number of times
     this query has been queried within the Google Search Engine. We
     have the index of times the query has been submitted overall, over
     time (by week), by country, by city and by language.

     This function needs access to a Google account to make the query.
     You can specify the account and password via the 'login'
     parameter. Alternatively, you can specify the  SID (session id)
     cookie for google.com by looking for it in your browser's
     collection of cookies, assuming you have an active session, i.e.
     signed/logged  into your Google account via your browser. If you
     are using Firefox as your browser, R can read the cookies directly
     from your browser.

_U_s_a_g_e:

     getGTrends(term, login, cookie = getGoogleCookies(), relativeScale = TRUE, curl = getCurlHandle(cookie = cookie))

_A_r_g_u_m_e_n_t_s:

    term: the topic or query term to query within Google Trends

   login: a named character vector with one element giving the login
          and password for the Google account, i.e. 'c(login =
          "password")'. 

  cookie: a string providing the cookies to use in the request. All we
          need is the cookie named SID (session id). These come from
          Google when you sign in.  We can retrieve them from Firefox's
          cookie list. Alternatively, you can specify them by hand as a
          character vector or a string in the form "SID=value".  In the
          future, you should be able to sign in to Google from within R
          and then we will reuse the same curl handle which will have
          the cookies returned by Google during the sign-in request.

relativeScale: a logical value indicating whether we want the  scaled
          or fixed counts.

    curl: a curl handle used in making the HTTP request. This can allow
          you to reuse existing connections and also to set curl
          parameters. If you specify this directly, you need not
          specify the cookies.

_D_e_t_a_i_l_s:

     The current version of this function reads the cookie information
     with which we communicate with Google from the browser. You must
     "Sign In" to Google using your browser. We then read the relevant
     cookies from the browser and use these. The names of the relevant
     cookie is SID (session id). At this point, we can only read from
     the  Firefox browser.

_V_a_l_u_e:

     A list of 5 data  frames. These provide information about the
     counts for the overall total, week, regions, cities and languages.

_A_u_t_h_o_r(_s):

     Duncan Temple Lang

_R_e_f_e_r_e_n_c_e_s:

     <URL: http://www.google.com/trends>

     This was motivated by Hal Varian's blog posting <URL:
     http://googleresearch.blogspot.com/2009/04/predicting-present-with-google-trends.html>.

     This is a nice example of how we get the cookies from our web
     browser, signing into Google using the browser (not R) and then
     logging.

_E_x_a_m_p_l_e_s:

     ## Not run: 
           # If you have logged in to your Google account via your Firefox browser
           # or set options(GooglePassword = c(login = password))
        ans = getGTrends("coupon")

        ans = getGTrends("coupon", c(mylogin = "password"))

         # Picks up c(login = password) from GooglePassword option
         # i.e. set with
         #     options(GooglePassword = c(login = "password"))
       g = googleSignIn()
       ans = getGTrends("coupon", curl = g)
     ## End(Not run)

