如何只从 Twitter 获取特定的字符串或记录
How to get only specific strings or records from Twitter
names(st)<-c("id_str", "created_at", "text", "location")
parseTweets(filterStream(file.name= "", track=c("climate change"), timeout=10, oauth=twitCred))$st
# [1] 6113 214 3649 1444 4483 270 8022 41946 494038 8925 3454 5249 20517 14790 14276 15316 583259 4254 3962 6635 52878 3669 2230 6186 9348 583267
#[27] 46894 17360 18038 3764
我不想看到这样的数字。我想看到实际的推文。例如
id_str created_at text location
xxx Mon Jun 01 16:52:33 ABCDEFG climate change UK
xxx1 Mon Jun 01 16:52:33 XYZCDF climate change Australia
xxxB Mon Jun 01 16:52:34 climate change XYZCDF USA
请在发布问题之前查看 ?parseTweets
底部的示例。
这一行的对象st
names(st)<-c("id_str", "created_at", "text", "location")
与 parseTweets
调用结束时的 st
无关。您正在使用 $
运算符,因此它通过搜索 $statuses_count
来完成字符串,该字符串也以 st
开头
删除 parseTweets 命令末尾的 $st
,您会发现您实际上需要 $text
列。
names(st)<-c("id_str", "created_at", "text", "location")
parseTweets(filterStream(file.name= "", track=c("climate change"), timeout=10, oauth=twitCred))$st
# [1] 6113 214 3649 1444 4483 270 8022 41946 494038 8925 3454 5249 20517 14790 14276 15316 583259 4254 3962 6635 52878 3669 2230 6186 9348 583267
#[27] 46894 17360 18038 3764
我不想看到这样的数字。我想看到实际的推文。例如
id_str created_at text location
xxx Mon Jun 01 16:52:33 ABCDEFG climate change UK
xxx1 Mon Jun 01 16:52:33 XYZCDF climate change Australia
xxxB Mon Jun 01 16:52:34 climate change XYZCDF USA
请在发布问题之前查看 ?parseTweets
底部的示例。
这一行的对象st
names(st)<-c("id_str", "created_at", "text", "location")
与 parseTweets
调用结束时的 st
无关。您正在使用 $
运算符,因此它通过搜索 $statuses_count
来完成字符串,该字符串也以 st
删除 parseTweets 命令末尾的 $st
,您会发现您实际上需要 $text
列。