在R中将推文转换为文本格式时出错

时间:2018-07-19 08:41:29

标签: r twitter sentiment-analysis

我想使用R对Twitter数据进行情感分析。我将我的数据集设为dataset.txt,在R中,我正在执行以下操作:

library(twitteR) ### for fetching the tweets
library(plyr) ## for breaking the data into manageable pieces
library(ROAuth) # for R authentication
library(stringr) # for string processing
library(ggplot2) # for plotting the results

tweets = read.table("E://dataset.txt",header = TRUE,sep = "," , quote = "\"",dec = ".", fill = TRUE, comment.char = "")
#for converting tweets to text format
tweets_txt = sapply(tweets[],function(x) x$getText())

此行出现错误:

tweets_txt = sapply(tweets[],function(x) x$getText())

,错误是:

Error in x$getText : $ operator is invalid for atomic vectors

我在哪里做错了?

我也从水槽生成了这个数据集,然后将其导出到hive中的表中,然后将其导出为txt文件,现在我想使用R做情感分析

dataset.txt中的一些文本是:

#SafeSchools
#ज्ञान_का_अखाड़ा ,दुनिया के सब जगह संत रामपालजी का ज्ञान (कबीर)  सुन रहे हे 
RT @Rkumars99: दिल्ली में मनमानी फीस पर स्कूलों का अधिग्रहण हो सकता है तो बच्चे की हत्या पर गुड़गांव में ऐसा क्यों नहीं हो सकता?
@BJP4India…
RT @alokg2k: #SafeSchools
Just wondering if Ryan school owner Pinto's have even cared to talk to Pradyumn's parents to pacify th… 
RT @k_satyarthi: How can we see a child go to school in uniform and return in a coffin? #SafeSchools. 2/3
RT @Gautam_p1251: Several others held a sit-in protest at the police commissioner’s office. #SafeSchools 
RT @hemantvyas6633: #SafeSchools
#ज्ञान_का_अखाड़ा में स्वागत है अखाड़ा परिषद का आओ ओर करो पराजित शास्त्रार्थ में #संतरामपालजीमहाराज को… 
RT @imNSharmaBJP: Congressi Trolling @narendramodi ji should also see this pics.
#RyanInternationalSchool Principle with Rahul Gandhi… 
RT @SatguruGreat: #ज्ञान_का_अखाड़ा में सभी धर्मगुरु बताए सन्त रामपाल जी महाराज से ज्ञान चर्चा के मैदान में क्यों नहीं आये ??
#ThatsWhyNSUI…
RT @Gautam_p1251: This is the worst you can expect after sending your child to school. #SafeSchools 
RT @GANESHYADAV82: #SafeSchools 
#ज्ञान_का_अखाड़ा
 सर्व सोने की लंका थी वो रावण से रान्दिरम , एक पलख मे राज बीरा जे जम के पड़े जंजीरम ।।
सा…

0 个答案:

没有答案