[英]How To Save a Variable as a Data Frame in R
我是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
嘗試Sent[[all]]
。 看看它是否有幫助。
我正在進行情緒分析。 對於極性,我使用qdap包並且對於所有評論都有相同的錯誤 - 對於單個句子以及單個單詞...為什么會發生這種情況?
library(qdap)
polarity("I love to eat")
derive_pubkey(key)出錯:
RAW()只能應用於'原始',而不是'列表'
我咨詢過這篇文章 。 我錯過了什么嗎? derive_pubkey(key)
- 這是什么意思?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.