我是R的新手,一般編程,並且正在嘗試創建一個程序來收集和分析來自twitter的數據。我使用的代碼如下:如何在R中保存一個變量作爲數據幀
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