r - 在 R 中将推文转换为文本格式时出错
问题描述
我想使用 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
#ज्ञान_का_अखाड़ा
सर्व सोने की लंका थी वो रावण से रान्दिरम , एक पलख मे राज बीरा जे जम के पड़े जंजीरम ।।
सा…
解决方案
推荐阅读
- .net - 使用oracle实体框架核心从.net core 3.1将Json obj ac Clob保存在Oracle DB中
- c# - 在每个请求中处理来自洋葱架构中标头的数据
- pine-script - 无法使用参数调用“strategy.order”(id=literal string,stop=series[float]);
- haskell - 在 Haskell 中建模单曲面相干性
- flutter - sqflite 与颤振的连接导致我出错
- php - 如何在 symfony 中使用自定义 gitlab 存储库
- javascript - 在类“a”中调用的“b”类的模拟方法
- python - 如何自定义单个子图的大小?
- rust - Rust:tokio 可以理解为类似于 Javascripts 的事件循环,或者像它一样使用吗?
- javascript - 如何在不将 java 脚本文件添加到 html 文件脚本的情况下访问 java 脚本中的网页域?