#@author Michael J Bommarito II
#@date Mar 12, 2011

# Thanks Hadley!
library(ggplot2)

# Load the sample
twitterDF <- read.csv('sample.csv', header=FALSE, stringsAsFactors=FALSE)

# Convert Twitter dates to POSIXct objects
twitterDF$date <- as.POSIXct(strptime(twitterDF$V4, "%a, %d %b %Y %H:%M:%S %z", tz = "GMT"))

# Plot the frequency at 10 minute interval
binSize <- 10
ggplot(data=twitterDF, aes(x=date)) + 
    geom_bar(aes(fill=..count..), alpha=0.5, binwidth=60*binSize) + 
    scale_x_datetime("Date") + 
    scale_y_continuous("Frequency") +
    opts(title="#march11/#saudi Tweet Frequency", legend.position='none')

ggsave(file='march11_tweets.pdf', width=8, height=6)