简体   繁体   English

Google R GTrendsR的趋势

[英]Google trends in R GTrendsR

I'm trying to use GTrendsR but is not working. 我正在尝试使用GTrendsR,但无法正常工作。 This is what I run 这就是我跑的

library(devtools)
#install_bitbucket("GTrendsR", "persican")
library(GTrendsR)
usr = "my gmail"
psw = "my password"
ch = gConnect(usr, psw)

location = "all"
query = "MOOCs"
MOOCs_trends = gTrends(ch, geo = location, query = query)
MOOCs_trends$SearchInfo

Everything seems to work but the last line gives me "NULL" 一切似乎正常,但最后一行给我“ NULL”

What am i doing wrong? 我究竟做错了什么?

Thanks! 谢谢!

It's because there's an error in the package where they aren't naming the columns in the dataframe. 这是因为在程序包中没有命名数据框中的列的错误。 I ran the same code and get 我运行了相同的代码并得到

> names(MOOCs_trends)
[1] ""    ""    ""    ""    "GEO"

But when you do: 但是当您这样做时:

>head(MOOCs_trends)
[[1]]
                   Week moocs
1   2004-01-04 - 2004-01-10     0
2   2004-01-11 - 2004-01-17     0
3   2004-01-18 - 2004-01-24     0

It works like it should. 它按应有的方式工作。 So the data is coming back. 因此数据又回来了。 A short term fix would be to access the list with numeric indices. 短期解决方法是使用数字索引访问列表。 Just do: 做就是了:

> MOOCs_trends[[1]]

etc... to access the different slots of data. 等等...访问不同的数据插槽。 It will take a quick code fix I'm sure to get the names right. 我将快速进行代码修复,我确定名称正确。 Alternatively you could add them yourself, but I'd suggest waiting for a code fix so future scripts don't break. 另外,您也可以自己添加它们,但是我建议您等待代码修复,以便将来的脚本不会中断。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM