0

so I'm trying to run 100 or so Google Trends queries (see code below) through R which I've done several times before with no errors

#load required package
library(gtrendsR)
library(tidyverse)
library(dplyr)

currentDate <- Sys.Date()
time <- "2010-01-01 2020-04-30"
channel <- "web"

#run queries
trends1 <- gtrends(keyword="compare", gprop=channel,geo="AU", time=time, category=249)
trends2 <- gtrends(keyword="switch", gprop=channel,geo="AU", time=time, category=249)
trends3 <- gtrends(keyword="change", gprop=channel,geo="AU", time=time, category=249)
trends4 <- gtrends(keyword="cancel", gprop=channel,geo="AU", time=time, category=249)
trends5 <- gtrends(keyword="contact", gprop=channel,geo="AU", time=time, category=249)
trends6 <- gtrends(keyword="quote", gprop=channel,geo="AU", time=time, category=249)

but now R is returning the same error after some (but not all) of the queries:

Error in `[<-.data.frame`(`*tmp*`, , timevar, value = "subject") : 
  replacement has 1 row, data has 0

If I run the query in the Google Trends website I see there is data so not sure what the error signals or why it appears on some queries and not others

DrPaul
  • 45
  • 6
  • Noticed that the issue was still occurring with just the gtrends query, so figured it was an issue with the gtrendsR package. Installed the previous version (1.4.5) and the issue went away. – DrPaul May 21 '20 at 23:36

1 Answers1

0

As you mentioned, it is a case of Google Trends Package Version. The same thing happened with me and I installed the old version of gtrendsR and it worked for me , you can download the old version from the link:

gtrendsR CRAN Repository

PS: Remember to Uninstall gtrendsR before installing, you may have to restart RStudio before installing