Skip to content
Browse files

add twitter code to generate a summary of conference tweets

  • Loading branch information...
1 parent ae5d88a commit 6460cb6dd34e974a75c9c173063db1d079637002 @cboettig committed Aug 13, 2012
Showing with 45 additions and 0 deletions.
  1. +45 −0 conf_twitter_summary.Rmd
View
45 conf_twitter_summary.Rmd
@@ -0,0 +1,45 @@
+---
+layout: post
+title: Tracking my ESA2012 experience through twitter
+
+---
+
+
+
+
+``` {r }
+library(twitteR)
+hashtag <- "#ESA2012"
+user <- "cboettig"
+````
+
+User's conference tweets
+
+``` {r }
+tweets <- twListToDF(userTimeline(user, n=500))
+tagged <- grep(hashtag, tweets$text, ignore.case=TRUE)
+````
+
+Write to file, making links appear as links
+
+``` {r comment=NA, results="asis"}
+text <- tweets$text[tagged]
+text <- gsub("(@[A-Za-z0-9_]+)", "<a href=\"http://twitter.com/\\1\">\\1</a>", text)
+text
+````
+
+Mentions at conference, (other than retweets)
+
+``` {r }
+mentions <- twListToDF(searchTwitter(paste("@", user, sep=""), n=300))
+with_hashtag <- grep(hashtag, mentions$text, ignore.case=TRUE)
+rt <- grep("RT\\s", mentions$text)
+me_not_rt <- with_hashtag[!(with_hashtag %in% rt)]
+````
+
+Again, write the output
+
+``` {r results="asis"}
+text2 <- mentions$text[me_not_rt]
+text2 <- gsub("(@[A-Za-z0-9_]+)", "<a href=\"http://twitter.com/\\1\">\\1</a>", text2)
+text2

0 comments on commit 6460cb6

Please sign in to comment.
Something went wrong with that request. Please try again.