Charting Wikipedia interest in GOP candidates with googleVis

I recently posted an article on how to collate Wikipedia page views

As there is a time component to this, it seemed appropriate to use the googleVis Package to visualize changes in page hits in the Google Motion chart

For this exercise, I ran the wikiFun function covered in the last post to collate page visits for the main Republican candidates for the Presidency. There are a couple of points worth mentioning so I have incorporated the relevant code

?View Code RSPLUS
# dataframe, GOPdata, has daily Wikipedia page views for leading candidates from beginning of 2011
# create and plot chart locally
myChart <- gvisMotionChart(GOPdata, idvar="name", timevar="date")
# set preferred initial state (e.g line rather than bubble chart etc.) then from
#Settings(the wrench) > Advanced > Advanced copy the state string to a variable
# enclose the copied string in single quotes exactly as below
initState <- ' 
   "orderedByY":false,"sizeOption":"_UNISIZE","iconKeySettings":[{"key":{"dim0":"Mitt Romney"}}],
# reproduce chart with
myChart <- gvisMotionChart(GOPdata, idvar="name", timevar="date", options=list(state=initState))
# copy the chart html to a file
cat(myChart$html$chart, file="GOP2012.html")

The html can then be massaged as required and uploaded. I would normally post this on this blog but I had difficulties using the suggested custom fields plugin and , in any case, it would probably be too large. It can be viewed here
N.B. Flash needs to be installed to view Google Charts

The graph reflects the changes in fortune of the participants quite well with eight different candidates having at least six days at the top. Now the election is nigh, however, Romney is outpacing his closest rival 10:1

Short URL:

Leave a Reply