3

I have been trying to pull Covid data from Gtrends but I am getting the following error:

I am using the grendsR package in R.

# google search for covid (week started XX - SUN): https://trends.google.com/trends/explore?geo=US-HI&q=covid
search_covid <- gtrends(keyword = 'covid', geo = 'US-HI', time = 'today+5-y') %>%
  pluck("interest_over_time") %>%
  as_tibble() %>%
  select(date, hits) %>%
  rename(search_covid = hits) %>%
  mutate(date = ymd(date) + days(1),
         search_covid = as.numeric(search_covid %>% ifelse(. == '<1', 0, .)))
search_covid %>% ts_plot()
search_covid %>% tail()

I am getting this error: Error in interest_over_time(widget, comparison_item, tz) : Status code was not 200. Returned status code:401

Any help would be appreciated.

OGC
  • 244
  • 3
  • 13
  • I tried adding this: ``search_covid <- gtrends(keyword = 'covid', geo = 'US-HI', time = 'today+5-y', gprop = c("web", "news", "images", "froogle", "youtube"), category = 0, hl = "en-US",low_search_volume = FALSE, cookie_url = "http://trends.google.com/Cookies/NID", tz = 0, onlyInterest = FALSE) `` but to no avail – OGC Jun 09 '22 at 00:05

1 Answers1

2

Reloading the gtrendsR package to the newer version seemed to have solved this problem:

install.packages("readr")
install.packages("colorspace")
install.packages("vctrs")
install.packages("gtrendsR")

Solution found from here: How to load google trends package in R

OGC
  • 244
  • 3
  • 13