Created
December 15, 2012 00:17
-
-
Save abecode/4289867 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read in data | |
timeSeriesElectionData <- read.table("twitterElectionTimeline_tsvWithHeader.txt",header=TRUE) | |
# Attach columns of data as variables in R environment | |
attach(timeSeriesElectionData) | |
# open a pdf file for writing | |
pdf(file="electionTimeline.pdf",height=4,width=12) | |
# plot the sum of tweets about obama and romney, as a line, with no x-axis ticks, bla bla... | |
plot(obama+romney, type='l',xaxt='n',xlab='Date',ylab="Number of Obama and Romney Tweets") | |
# create a sequence of dates, from Mar. 1 to Dec. 1, by month | |
d <- seq.Date(from=as.Date('2012-3-01'), to=as.Date('2012-12-01'),by='month') | |
# find the number of data points: | |
length(obama) | |
# output: [1] 1068 | |
# write the dates as axis ticks | |
axis(side=1,labels=d,at=seq(from=1,to=1068,length.out=10),cex.axis=0.8,las=2) | |
#close the pdf file | |
dev.off() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment