2016-11-25 11 views
4

私は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 $ Patientcommentを取る、そこからデータテーブルであるように、データフレームとしてPAT1を保存する方法を把握しようとしています。

私は今、プログラムを実行すると、私は次のような結果を得る:

> 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 

答えて

1

Sent[[all]]を試してみてください。それが役立つかどうかを見てください。

0

私は感情分析に取り組んでいます。極性については、qdapパッケージを使用して、すべてのレビューで同じエラーが発生しました.1つの単語だけでなく1つの単語に対しても... なぜこれが起こっていますか?

library(qdap)  
polarity("I love to eat") 

derive_pubkeyでエラーが発生しました(キー):
RAWは()のみ、私はthis articleに相談 '生の'、ではない 'リスト'

に適用することができます。私が逃したものはありますか? derive_pubkey(key) - これはどういう意味ですか?

関連する問題