Google Trends in R
I am trying to import Google Trend results into R.
I have tried rGtrends and RGoogleTrends. The first seems to get stuck downloading the CSV file:
> require(devtools)
> install_github("rGtrends","emhart")
> library(rGtrends)
> my_terms <- c("Twitter", "Myspace")
> twit_ms <- rGtrends(my_terms)
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:/.../Documents/R/win-library/3.0/rGtrends/src/pyGTrends.py", line 105, in csv
raise Exception("Could not find requested section")
The second I having problems with signing in (not sure why I need to give my google username and password anyway? I can explore google trends in my browswer without doing so.)
This isn't an R issue.
A quick read of the comments section on the pyGTrends home page and of the issues section of rGTrends reveals an ongoing listing of various causes for this type of behavior and it seems that the main culprit is authentication changes with google trends. ie: Sometimes pyGTrends works for some with 2 factor authentication, and other times for others it doesn't; sometimes the user needs to set a cookie and sometimes not.
Try this. It should work with the most current Google trend data format.
require(devtools)
install_github('googletrend','okugami79')
library(googletrend)
# You need to Login http://google.com/trends on your browser!!
x<- gettrend(keyword='Twitter')
链接地址: http://www.djcxy.com/p/71178.html
下一篇: 谷歌趋势在R