I am gathering Google Trends data using the R Package gtrendsR. I am trying to pull data for each metropolitan statistical area (MAS) but area code would also be good. So far I have only managed to get the state-level data. Here is the code for that.
example <- gtrends("car", geo="US-FL")$interest_over_time
I have tried the following for the MSA:
example2 <- gtrends("car", geo="US-FL-Jacksonville FL")$interest_over_time
and for the area codes:
example3 <- gtrends("car", geo="US-FL-904")$interest_over_time
I get errors saying that the package cannot retrieve valid codes. In data("countries") associated with the package, the codes are only for state-level - e.g. US-FL for Florida.
I would be interested in knowing how I can retrieve more granular data with this package, along the lines described in example2 and example3 above.
To retrieve data for "Jacksonville, FL", you should use
geo = "US-FL-561"
:To find the geo code for cities, you can use this code (you can replace
"US-FL"
by any country-states code you want):Function
If easier, you can also write the code as a function:
Examples