You can import Google Trends data into Displayr.
The results are scores indicating search frequencies over time, in the range 0 to 100. The scores are relative, such that the difference between the highest score and lowest score is close to 100. Thus comparing apples with oranges may result in different scores for oranges than when comparing bananas with oranges. See the Google Trends website for more information.
This article describes how to import Google Trends data...
... and chart it over time.
Note that results are relative to the total number of searches at each time point, with the maximum being 100. See here for an explanation of Google's methodology.
Requirements
- A Displayr document
Method
1. Select Anything > Data > Miscelleaneous > Google Trends.
2. Enter the search term in the Topic(s) field of the object inspector. In this example, we will enter "blu-ray" to see its rise and fall over time. If you have more than one topic, separate the terms with a comma.
3. Change the Period field to 2004-Present. You can select Custom range to enter a specific date range.
4. OPTIONAL: Change Type to narrow the search.
5. OPTIONAL: If you wish to show multiple regions, change Region to Multiple regions and enter Region codes separated by a comma. See ISO regions for a list of available country codes.
To display a list of all country and regional subcodes, select Calculation > Custom code and enter geo.codes =
gtrendsR::countries
.
6. From the object inspector, go to Visualization > Line > Line.
Options
The following options are available when extracting Google Trends data. The options in the Object Inspector are organized into two tabs: Inputs and Properties.
Inputs
- Topic(s) The topic(s) to be searched for. Where there is more than one topic, they should be comma-separated.
- Type Whether to search the web, news, images, YouTube, or Google Shopping.
- Region Either World, a selected country from the list, a State, or Multiple regions.
- State code If State is selected, use the ISO-3166 code (e.g., US-CA for California or AU-NSW for New South Wales in Australia). See this link for more information on ISO 3166 codes.
- An imperfect mechanism for extracting the relevant state-based codes of a country is to create an R Output and paste in the two lines of code below, replacing the US with the appropriate country code. It is imperfect because many of the codes that are returned will not work.
-
library(gtrendsR)
geo.codes <- sort(unique(countries[substr(countries$sub_code, 1, 2) == "US",]$sub_code))
- Region codes If Multiple regions is selected, use a comma-separated list of either ISO-3166 country or state codes (e.g. FR, MX, GB for France, Mexico, and Great Britain). See this link for more information on ISO 3166 codes. A mixture of countries and states is not permitted.
- Period The time period for which the Google Trends are reported. Either Custom range (yyyy-mm-dd) or a specific period. The frequency of the data points depends on the period as follows,
-
- Last hour and Last 4 hours : every minute
- Last 24 hours : every 8 minutes
- Last seven days : hourly
- Past 30 days and Past 90 days : daily
- Past 12 months and Last five years : weekly
- 2004 - present : monthly
- Long format output If checked, the result is returned in long format i.e. with one row of data per topic per time period. Otherwise, it is returned in wide format i.e. with time periods along the rows and topics along the columns.
- Automatic updating Whether to regularly update the data.
- Update period The time unit for regular updates.
- Frequency The multiple of the Update period for regular updating.
- Start date and time The date and time of the first update in the format dd-mm-yyyy hh:mm or mm-dd-yyyy hh:mm.
- US date format Whether the Start date and time is expressed in US format i.e. mm-dd-yyyy hh:mm.
- Time zone An optional time zone for the Start date and time, or else default of UTC applies. Format must be Continent/City, e.g. America/Los_Angeles. See Wikipedia for a list of time zones.
- Update exported documents Whether exported documents that refer to the data should also be updated regularly.
Properties
This tab contains options for formatting the size of the object, as well as the underlying R code used to create the visualization, and the JavaScript code used to customize the Object Inspector itself (see Object Inspector for more details about these options). Additional options are available by editing the code.
Acknowledgments
Uses the gtrendsR package.
Next
How to Import Data into Displayr