Wikipedia has a useful little resource: opinion polls for New Zealand politics dating back to 2005. The poll results are in different pages according to which election they preceded. They also have charts showing the aggregated results of these polls, generated by R scripts written by the Wiki authors. There’s a sample of one of these scripts here.
What I’d like – what I think a lot of people would like – is a script that compiled all of the polls into one big table, and then let you specify the date range for the chart you wanted to generate. I can’t program in R and I don’t have time to learn right now, so if anyone out there has a little R experience and a spare hour or two then I’d really like to hear from you. I’ll put some pseudo-code on how I’d like the script to work over the break.
If we can get this working I’ll make a permanent page on the site and post the code with some instructions. I think it would be useful to researchers, as well as politics geeks like me.
#date variables that can be modified
daterangestart = 01/01/2005
daterangeend = today
#build an array of html results; array should be dynamic so you can add future wiki pages for future elections
loop through the array, find the tables as per the current script linked above and aggregate them all into one matrix, checking to see that the top and tails aren’t duplicates. Add a column that indicates if an entry is a general election result instead of a poll
create the chart and dynamically allocate tick marks appropriate to the date range variables given above
now populate the chart based on date range variables, and apply smoothing to the data series, and indicate CI as per the script linked above.
add black bar down the y axis every time there’s a general election entry