2012-05-03 14 views
2

ツイートの情報を取得するのに、TwitteRパッケージとRプログラムを使用しています。 TwitterのAPIが特定のツイートのリツイート件数

retweet_count’ function(https://dev.twitter.com/docs/faq#6899) 

を提供していても、私はR.以内にそれを活用する方法を見つけ出すことができませんでした(たぶん「RCurl」パッケージに「getURL」関数を使用して?)

を基本的には、私が探しています

  1. 特定のつぶやきがリアルタイム情報を取得するためにRでストリーミングAPIを使用して

  2. をリツイ​​ートされた回数にする方法

    a。新しいフォロワーがこれらのユーザーに参加し、

    b。つぶやくかリツイートを投稿すると、

    cです。彼らが投稿したつぶやきが他の人によって再ツイートされたとき

誰かがこれらの情報を得るためにリードを見つけるのを手伝ってくれたら嬉しいです。

答えて

3

私はストリーミングAPIに関する質問にお答えできませんが、返信を扱う場合はthis helpful tutorialに基づいてどうでしょうか。おそらくそれを使って、ユーザーごとのリツイート数の代わりに特定のつぶやきに集中することができます。 posts hereのうちのいくつかがより有用かもしれません。

# get package with functions for interacting with Twitter.com 
require(twitteR) 
# get 1500 tweets with #BBC tag, note that 1500 is the max, and it's subject to mysterious filtering and other restrictions by Twitter 
s <- searchTwitter('#BBC', n=1500) 
# 
# convert to data frame 
df <- do.call("rbind", lapply(s, as.data.frame)) 
# 
# Clean text of tweets 
df$text <- sapply(df$text,function(row) iconv(row,to='UTF-8')) #remove odd characters 
trim <- function (x) sub('@','',x) # remove @ symbol from user names 
# 
# Extract retweets 
library(stringr) 
df$to <- sapply(df$to,function(name) trim(name)) # pull out who msg is to 
df$rt <- sapply(df$text,function(tweet) trim(str_match(tweet,"^RT (@[[:alnum:]_]*)")[2]))  
# 
# basic analysis and visualisation of RT'd messages 
sum(!is.na(df$rt))    # see how many tweets are retweets 
sum(!is.na(df$rt))/length(df$rt) # the ratio of retweets to tweets 
countRT <- table(df$rt) 
countRT <- sort(countRT) 
countRT.subset <- subset(countRT,countRT >2) # subset those RTd at least twice 
barplot(countRT.subset,las=2,cex.names = 0.75) # plot them 
# 
# basic social network analysis using RT 
# (not requested by OP, but may be of interest...) 
rt <- data.frame(user=df$screenName, rt=df$rt) # tweeter-retweeted pairs 
rt.u <- na.omit(unique(rt)) # omit pairs with NA, get only unique pairs 
# 
# begin sna 
library(igraph) 
g <- graph.data.frame(rt.u, directed = T) 
ecount(g) # edges (connections) 
vcount(g) # vertices (nodes) 
diameter(g) # network diameter 
farthest.nodes(g) # show the farthest nodes 
+0

ありがとうございます!私はこれを検討します。 – user1371835

関連する問題