Data EcologyPractical
Exercises
Worksheet 5 – Google Trends
Objectives: The objective of this practical exercise is to investigate the use of Google Trends
both through a web browser and using the R package gtrendsR API to directly access the
data on-line.
Task1: Please install the package of gtrendsR in RStudio.
Task2: Using a web browser, go to https://trends.google.com/trends/ and insert a search
term or phrase of your choice. This should be something fairly seasonal e.g. ‘The
Proms’. Select United Kingdom and for 5 years. This is weekly data. Download the
data to csv. Change the time period to 2004-present (this is monthly data) and again
download the data. Go down to the next panel and click on England to see which
cities are high on the list of Googling your topic. These data can be downloaded if
required. Click +Compare and add another term e.g. ‘last night of the Proms’. Study
the overall result. Notice other searches categories such as image and YouTube.
Task3: Start R Studio and load the script Gtrends_D7001_Oct2020.R. Edit lines 19 and 31-33
in Section 01 to contain your first keyword or phrase and if desired, the data range
(keep it to 5 years maximum so as to have weekly data. Run Section 01 only. Inspect
the plot to see that it corresponds to the web browser interface. Export the line chart
for the portfolio.
Task4: Edit line 37 in Section 02 to contain your second keyword or phrase and if desired,
the data range (keep it to 5 years maximum so as to have weekly data. Run Section
02 only. Inspect the plot to see that it corresponds to the web browser interface.
Export the line chart and test the correlation of your first and second keywords for
the portfolio.
Task5: Edit lines 48, 53, 63 and 65 in Section 03 to plot the Goole Trends of both your first
and second keywords. Run Section 03 only. Export the line chart for the portfolio.
Task6: Choose another pair of keywords and repeat Task3, Task4 and Task5. I hope you
could find one pair of keywords with real correlation and another pair of keywords
with spurious correlation. Put your comments about the correlations of your two
pairs of keywords in the portfolio.
Output to portfolio: The line chart showing the real and spurious correlations using the R API
gtrendsR.
1
AssignmentTutorOnline