google_trends: Get data from Google Trends

Description Usage Arguments Value Note Examples

Description

This function scrapes Google Trends and returns the results nicely formatted into a R object

Usage

1
2
3
google_trends(query, country = "all", region = "all", date = "all",
  fromdate = NULL, todate = NULL, category = "all",
  sub_category = "all")

Arguments

query

The keyword to be searched. It will be auto escaped.

country

Country name, i.e: United Kingdom, Italy, Germany, etc. Deafult option is the worldwide search.

region

Region name, i.e: England, Scotland, etc. Deafult option is all. It is possible to use only the region name without specifying the related country.

date

The time span. Default is all. Other options are: 'last 7 days', 'last 30 days', 'last 90 days', 'last year' or the year number, i.e '2014'

fromdate

If fromdate and todate are both specified the time span will be the custom one. Specifiy the values as strings in the format YYYY-MM-DD.

todate

See fromdate

category

The parent category of the keyword. Default is all. The options are listed in the data GT_Options$Category dataframe

sub_category

The child category of the keywrod. Default is all.

Value

The output is a list. This list contains the trend, the geographical segmentation (countries and cities), the suggested categories for the keyword and the related searches

Note

Please note that (except for the query argument) all the other arguments are case INSENSITIVE

Examples

1
2
3
4
5
6
7
#Search the keyword 'test me' in England for last 30 days
results = google_trends(query = "test me", region = "England", date = "last 30 days")

#Access all available arguments
data(Google_Trends_Data)
#i.e: Check available categories
unique(GT_Options$Category$name)

RossiLorenzo/trendR documentation built on May 9, 2019, 10:32 a.m.