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
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 (104)
Related posts:
- Notes on a Scandal – When Jimmy beat Katy No the title doesn’t refer to how Katy Perry suffered at another of Jimmy Savile’s sexual predelictions, although these are two of  the participants. I’ll get to the details...
- giRls Rule ‘Expansed’ recently posted a blog article on visualising Wikipedia search statistics with R I have adapted his great script to compare the number of wiki hits four of the top...
- Margins of Victory This is a repost from a few days ago that I am using as my introduction to the R-bloggers site. Having experimented with R lately, I have decided to add...
I loaded http://www.premiersoccerstats.com/GOP2012.html in Firefox 16.0.2 on Windows 7, but it comes up blank. I don’t see any errors in the FF error console except that the character encoding is not declared.
The problem is I don’t have Flash installed. Other sites give me a popup / warning, but not this one. The site works fine on my other browser.
Breathtaking! I’m new to R and the techniques you discuss really make me want to learn more and more! Thanks a lot!
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