我是R和一般编程的新手,我正在尝试创建一个从twitter收集和分析数据的程序。我使用的代码如下:
install.packages(c("devtools", "rjson", "bit64", "httr"))
library(devtools)
library(twitteR)
APIkey <- "xxxxxxxxxxxxxxxxxxxxxx"
APIsecret <- "xxxxxxxxxxxxxxxxxxxxxxxxx"
accesstoken <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
accesstokensecret <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
setup_twitter_oauth(APIkey,APIsecret,accesstoken,accesstokensecret)
Pat1$Patientsentiment <- tolower (Pat1$Patientcomment)
library(qdap)
Sent<-polarity(Pat1$Patientcomment, grouping.var = Pat1$Pat.NUMBER,
positive.list = positive.words,
negative.list = negative.words,
negation.list = negation.words,
amplification.list = increase.amplification.words,
rm.incomplete = FALSE, digits = 3)
RPatient_Polarity <- data.frame(Sent$all)
我正在尝试弄清楚如何将Pat1保存为一个数据框,这样Pat1就是一个数据表,您可以从该数据表中将Pat1$Patientcomment作为变量。
当我现在运行这个程序时,我得到了以下结果:
> library(devtools)
> library(twitteR)
> APIkey <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> APIsecret <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> accesstoken <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> accesstokensecret <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> setup_twitter_oauth(APIkey,APIsecret,accesstoken,accesstokensecret)
[1] "Using direct authentication"
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called
setup_twitter_oauth()'
> Pat1$Patientsentiment <- tolower (Pat1$Patientcomment)
> library(qdap)
> Sent<-polarity(Pat1$Patientcomment, grouping.var = Pat1$Pat.NUMBER,
+
+ positive.list = positive.words,
+
+ negative.list = negative.words,
+
+ negation.list = negation.words,
+
+ amplification.list = increase.amplification.words,
+
+ rm.incomplete = FALSE, digits = 3)
Error in derive_pubkey(key) :
RAW() can only be applied to a 'raw', not a 'list'
> RPatient_Polarity <- data.frame(Sent$all)
Error in data.frame(Sent$all) : object 'Sent' not found
发布于 2016-11-26 01:38:25
试试Sent[[all]]
。看看有没有帮助。
发布于 2016-12-02 14:50:48
我正在做情绪分析。对于极性,我使用了qdap包,并且在所有评论中都有相同的错误-对于单个句子和单个单词...为什么会发生这种情况?
library(qdap)
polarity("I love to eat")
Derive_pubkey(密钥)中的
错误:
RAW()只能应用于“raw”,而不能应用于“list”
我咨询了this article。是不是我错过了什么?derive_pubkey(key)
-这是什么意思?
https://stackoverflow.com/questions/40809870
复制相似问题