A question about Google Trends package gtrendsR.
I have written my code as follows:
install.packages('gtrendsR')
library(gtrendsR)
# Define the key words
keywords = c("x", "y", "d", "e", "f")
# Set the geographic area: DE = Germany; DK = Denmark
country = c('DE','DK')
# Set the time window
CurrentDate <- Sys.Date()
time=("2018-01-01 CurrentDate")
# Set channels
channel = 'web'
trends = gtrends(keywords, gprop = channel, geo = country, time = time)
R gives me two errors: (1) Error in gtrends(keywords, gprop = channel, geo = country, time = time) : (length(keyword)%%length(geo) == 0) || (length(geo)%%length(keyword) == .... is not TRUE
which appears because I try to use two locations;
(2) Cannot parse the supplied time format., if I only leave 'DE' for the country. Then, it does not read the CurrentDate value.
My question is how I should write the code to get more than one country at the time? And how should I code the date to get the most recent date every time I run the code?
Thank you.
I found two issues in your approach:
keywordargument and not withgeo. I could not guess it. Maybe its length."2018-01-01 CurrentDate"From the help ofgtrends:Issue #1 prevents the occurence of issue #2.