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
 
library(googleVis)
 
# 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")
plot(myChart)
 
# 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 <- ' 
  {"nonSelectedAlpha":0.4,"yZoomedDataMin":0,"yLambda":0,"yZoomedDataMax":600000,
   "xZoomedIn":false,"xZoomedDataMin":0,"yZoomedIn":false,"time":"2011","playDuration":15000,
   "orderedByY":false,"sizeOption":"_UNISIZE","iconKeySettings":[{"key":{"dim0":"Mitt Romney"}}],
   "xLambda":1,"colorOption":"_UNIQUE_COLOR","duration":{"multiplier":1,"timeUnit":"D"},
   "yAxisOption":"2","dimensions":{"iconDimensions":["dim0"]},"iconType":"VBAR",
   "uniColorForNonSelected":false,"orderedByX":true,"xZoomedDataMax":9,"showTrails":false,
   "xAxisOption":"2"}
'
 
# reproduce chart with
myChart <- gvisMotionChart(GOPdata, idvar="name", timevar="date", options=list(state=initState))
plot(myChart) 
 
# 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: http://tinyurl.com/muq3n22

4 thoughts on “Charting Wikipedia interest in GOP candidates with googleVis

  1. pssguy Post author

    I think this is a Flash issue. It needs to be installed. As you say there is normally
    a pop up in this situation but I have highlighted the need on the post and by the table now

Leave a Reply