我想通过 for 循环获取谷歌趋势数据。然而,一个错误让我退缩了。在搜索其他堆栈问题后,我仍然无法使其工作。有问题的循环:
a2p = for (i in dfurlnames$names1)
{
x<- paste(i)
gtrends_function3(x)
}
在我的 for 循环中,我收到以下错误:
Error : res$status_code == 200 is not TRUE
我使用以下包和功能:
获取新的 gtrendsR;devtools::install_github('PMassicotte/gtrendsR')
library(gtrendsR)
gtrends_function3 <- function(x)
{
trend1 = gtrends(c(x), geo = c(""), time = "2014-01-05 2014-10-04")
trend_df1 = ldply(trend1)
return(as.numeric(trend_df1$hits))
}
名单:
dfurlnames$names1 = Ang babaeng humayo, The Bad Batch, Une vie, La La Land,
The Light Between Oceans, El ciudadano ilustre, Spira Mirabilis, La región
salvaje, Nocturnal Animals