Hi all,
I have a question relating to the output of R when downloading Google trends data.
I want to download Google trends data for the past 7 days.
My code is:
Hi,
Thank you for replying. I know the question may sound ridiculous. I've just got to know R for 2 days. I have to download data from Google trends for a bunch of search keys, and want to find a quicker way to do rather than manually download one by one each time. Someone told me I can use R. The code I wrote is the result after reading some stuff on the Internet. I combined it from different websites but don't really know how the commands work.
I tried to run the code you gave me. But there are errors:
library(gtrendsR)
library(readr)
Error in library(readr) : there is no package called ‘readr’
temp = gtrends(c("VCB"), geo = "VN", time = "now 7-d", gprop = c("web"), category = 7, hl = "en-US", low_search_volume = TRUE)
temp = temp$interest_over_time
write_csv( temp, "output1.csv",)
Error in write_csv(temp, "output1.csv", ) :
could not find function "write_csv"
Could you patiently help me to solve the problem? I need to download Google trends data for the past 7 days for a list of search key.
I did it successfully. Thank both of you for helping me.
I still wonder: is there any way to create a loop so that I can download data for a list of search key without coding for each search key?
And how can I adjust the time of downloading SVI to match with the geographic location I choose?
If your question's been answered, would you mind choosing a solution? (see FAQ below for how) It makes it a bit easier to visually navigate the site and see which questions still need help.
When I open the output data, which is saved as CSV, I saw that the time of last observation is not set to both geo location's time zone and machine's time zone. I downloaded past 7 day data, which is hourly data. I can see big difference when look at the hour. Thats why I ask this question. I wonder if there is any relation with CRAN.
In the code above, lubridate's tz function will reveal the timezone of those datetime observations. As I said, saving to CSV will stripe timezone information away.
It appears to be the machine's timezone in my example.