twListToDF (twitteR package)

Summarize information about a list of tweets in a data frame. This function is useful for handling output from the publicTimeline, userTimeline, and searchTwitter functions.
  • twList – A list of status objects, which is just a list of tweet objects.

Example. Barack Obama’s Twitter feed is retrieved and his posting frequency over the last several years is plotted. The peak in the plot is July 29th, 2011, at the time of the debt ceiling crisis. An erroneous post is removed using [-1] in the line initializing the counts variable.
> library(twitteR)
Loading required package: RCurl
Loading required package: bitops
Loading required package: RJSONIO
> result <- userTimeline("BarackObama", n=3200)
> length(result)
[1] 2975
> tweet.df <- twListToDF(result)
> Created  <- tweet.df$created
> counts   <- table(as.Date(Created))[-1]
> dates    <- as.Date(names(counts))
> # png("twitteR-BarackPosts.png", 650, 500)
> plot(dates, counts, type="h")
> #

Other functions used in the example: userTimeline, as.Date, png.
Comment. Today was the last post on the twitteR package, at least for now. For those wanting more, the package vignette would be a good starting point. Or you can post a comment to voice your support of more Twitter or other social media on the blog.

Leave a Reply