I have multiple terms and would like to know how the terms compare to each other on the same day:
search_terms <- c("apple", "oranges")
gtrends(keyword = search_terms,
geo = "US",
time = "2022-03-01 2022-03-01",
onlyInterest = TRUE) -> output_results
I am currently getting the error, Error: Cannot parse the supplied time format.
I get results when I add a few more days. Is there a way to get around this so I can just get results for one particular day?
CodePudding user response:
According to the docs you should have between two dates:
"Y-m-d Y-m-d" Time span between two dates (ex.: "2010-01-01 2010-04-03")
So what you can do is take it a day later and filter the desired date later out. Here is a reproducible example:
library(gtrendsR)
library(dplyr)
library(lubridate)
search_terms <- c("apple", "oranges")
gtrends(keyword = search_terms,
geo = "US",
time = "2022-03-01 2022-03-03",
onlyInterest = TRUE) -> output_results
output_results$interest_over_time %>%
filter(date == ymd("2022-03-01"))
#> date hits keyword geo time gprop category
#> 1 2022-03-01 96 apple US 2022-03-01 2022-03-03 web 0
#> 2 2022-03-01 2 oranges US 2022-03-01 2022-03-03 web 0
Created on 2023-01-17 with reprex v2.0.2