2

「TwitteR」パッケージとRプログラムを使ってツイート情報を取得しています。TwitterAPIが提供しているにもかかわらず

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

R内でそれを利用する方法を理解できませんでした(多分getURL'RCurl'パッケージの''関数を使用していますか?)

基本的に、私はする方法を探しています

  1. 特定のツイートがリツイートされた回数

  2. RでストリーミングAPIを使用して、次のようなリアルタイム情報を取得します。

    a。新しいフォロワーがそれらのユーザーに加わり、

    b。ツイートやリツイートを投稿するとき、

    c。彼らが投稿したツイートが他の誰かによってリツイートされたとき

誰かがこれらの情報のいずれかを取得するためのリードを見つけるのを手伝ってくれるとありがたいです。

4

1 に答える 1

3

ストリーミング API の質問にはお答えできませんが、この役立つチュートリアルに基づいて、リツイートを操作するにはどうすればよいでしょうか。ユーザーごとのリツイート数ではなく、特定のツイートに焦点を当てるために、おそらくそれを使用することができます. ここの投稿のいくつかは、より役立つかもしれません。

# 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
于 2012-05-03T08:01:56.573 に答える