Skip to content

Instantly share code, notes, and snippets.

@thoughtfulbloke
Created September 24, 2017 02:55
Show Gist options
  • Save thoughtfulbloke/2925675818970e8a0b19276234bec603 to your computer and use it in GitHub Desktop.
Save thoughtfulbloke/2925675818970e8a0b19276234bec603 to your computer and use it in GitHub Desktop.
library(dplyr)
library(tidyr)
library(ggplot2)
# from http://www.elections.org.nz/events/2017-general-election/2017-general-election-party-lists
listText <- "number person
NA ACT NEW ZEALAND
1 SEYMOUR, David
2 HOULBROOKE, Beth
3 VAN VELDEN, Brooke
4 SINGH, Bhupinder
5 BERRY, Stephen
6 PEDERSEN, Stuart
7 CARLSON, Anneka
8 NG, Shan
9 PURCHAS, Sam
10 SEVERIN, Toni
11 O'SULLIVAN, Grae
12 EVANS, Richard
13 McDOWALL, James
14 WELLS, Richard
15 WARREN, Michael
16 MOORE, Andie
17 PARKINS, Andy
18 CARLEY, Bruce
19 CORBETT, Tom
20 DAVIDSON, Brian
21 DAVIDSON, Alan
22 DOUGHTY, Daniel
23 EVANS, Alex
24 GILBERT, Paul
25 GREENSLADE, Roger
26 HAWKINS, Stuart
27 HAYCOCK, Bruce
28 HUFFLETT, Paul Charles
29 KEARNEY, Nick
30 KRONFELD, Tim
31 MISSELBROOK, Joe Elwood
32 NELSON, Craig
33 PERRY, Joshua
34 SINGH, Sam
35 SMITH, Anthony
36 SOLE, Chris
37 WILSON, Neil
38 FLETCHER, Stephen
39 GRATTAN, Wayne Desmond
NA AOTEAROA LEGALISE CANNABIS PARTY
1 HERBERT, Maki
2 LYE, Jeff
3 LAMBERT, Paula
4 BRITNELL, Mike
5 MIHAERE KINGI, Emma-Jane
6 SHIRIWASTOW, Vineet Prasad
7 SAXBY-KONING, Jonee
8 McDERMOTT, Adrian
9 SHUFFLEBOTHAM, Janine
10 WILKINSON, Steven
11 SAXBY, Jeanette
12 BROWN, Tony
13 ROBIN, Rebecca
14 McTAGUE, Geoff
NA BAN1080
1 GRAF, Clyde
2 WALLACE, William John
3 SALTER, Peter
4 ADAMS, Brian Alan
5 SAWYER, Carol
6 HILTON, James Edwin
7 TOMLINSON, Glen James
8 HANSON, Kenneth Lloyd
9 MOLLOY, Mary
NA CONSERVATIVE
1 BAKER, Leighton
2 IKILEI, Elliot
3 TAYLOR, Mel
4 STITT, Kevin
5 FRAUENSTEIN, Martin
6 ASHTON, Lachie
7 DAVIE, Kathryn
8 WELSH, Bruce
9 DAVIE, Paul
10 LARKINS, Roger
11 JOHNSON, Jeff
12 PRICE, Benjamin
NA DEMOCRATS FOR SOCIAL CREDIT
1 DE RUYTER, Stephnie
2 LEITCH, Chris
3 JOBSIS, Jason
4 MacARTHUR, Scott
5 VAN WIEREN, Hessel
6 LEITCH, Andrew
7 RANSOM, Katherine
8 BRIGGS, Simon
9 RHODES, Mischele
10 MATTHYS, Karl
11 COLLIN, Jack
12 McCONACHY, Heather Ann
13 RING, John
14 PEMBERTON, John
15 RYAN, Dick
16 McKENZIE, Carolyn
17 WILSON, David Angus
18 SMITH, Heather Marion
19 LIVINGSTON-POOLEY, Tracy
20 ADCOCK-WHITE, Peter
21 PULFORD, Barry
22 CHEEL, Tricia
23 McCASKEY, John
24 GRIBBEN, Gary
25 MOWAT, Miriam
26 RICHARDS, Robert
NA GREEN PARTY
1 SHAW, James
2 DAVIDSON, Marama
3 GENTER, Julie Anne
4 SAGE, Eugenie
5 HUGHES, Gareth
6 LOGIE, Jan
7 SWARBRICK, Chlöe
8 GHAHRAMAN, Golriz
9 MATHERS, Mojo
10 COATES, Barry
11 McDONALD, Jack
12 HART, John
13 ROCHE, Denise
14 HOLT, Hayley Doreen
15 CROSSEN, Teall
16 TUIONO, Teanau
17 TAMU, Leilani Leafaitulagi
18 LAWREY, Matt
19 KEREKERE, Elizabeth
20 PERLEY, Christopher John
21 MENENDEZ MARCH, Ricardo
22 ZHU, Julie
23 LECKINGER, Richard
24 NASH, Thomas
25 TAYLOR, Sam
26 FULTON, Kate
27 WOODLEY, Tane
28 WRIGLEY, Jo
29 HOLWELL, Ash
30 GRAND-MEYER, Stefan
31 McCANDLESS, Robin Campbell
32 BOULD, Niki
33 GALLAGHER, Shane
34 SUMMERFIELD, Scott
35 SURENDRAN, Rochelle
36 WALSH, Bridget
37 GOLDSMITH, Rachael
38 WALL, Pat
39 GOODHUE, James
40 WESLEY, Richard
41 HUNT, Guy
42 DYETT, Elaine
43 FERGUSON, Sam
44 GILLIES, Richard
45 HODGE, Emma-Leigh
46 HORN, Chrys
47 JAUNG, Rebekah
48 LEE, David
49 MAYNE, Nicholas
50 MOORE, Robert
51 PATRICK, Nicola
52 RICHARDSON, Peter
53 RUDOLPH, Godfrey James
54 RUSDEN, Damon
55 SANDILANDS, Julie
56 SINGH, Raj
57 SMITH, Nicola
58 STEVENSON, Philippa
59 SWEET, Cathy
NA INTERNET PARTY
1 DAWSON, Suzie
2 COONEY, Ben
3 GOULDER-HOROBIN, Daymond
4 BOOTH, Jo
5 BEDFORD-PALMER, Blake
6 KING, Bruce James
7 SMITH, Nicholas Andrew Spencer
8 TURNER, Jourdan
NA LABOUR PARTY
1 ARDERN, Jacinda
2 DAVIS, Kelvin
3 LITTLE, Andrew
4 ROBERTSON, Grant
5 TWYFORD, Phil
6 WOODS, Megan
7 HIPKINS, Chris
8 SEPULONI, Carmel Jean
9 CLARK, David
10 PARKER, David
11 NASH, Stuart
12 RADHAKRISHNAN, Priyanca
13 HUO, Raymond
14 LEES-GALLOWAY, Iain Francis
15 TINETTI, Jan
16 SIO, Aupito Tofae Sua William
17 PRIME, Willow-Jean
18 O'CONNOR, Damien
19 SALESA, Jenny
20 FAAFOI, Kris
21 ALLAN, Kiri
22 JACKSON, Willie
23 CURRAN, Clare
24 DYSON, Ruth
25 WILLIAMS, Poto
26 WALL, Louisa
27 WOOD, Michael Philip
28 ANDERSEN, Ginny
29 LUXTON, Jo
30 RUSSELL, Deborah
31 CRAIG, Liz
32 LUBECK, Marja
33 MALLARD, Trevor
34 EAGLE, Paul
35 COFFEY, Tamati
36 STRANGE, Jamie
37 KANONGATA'A-SUISUIKI, Anahila
38 McANULTY, Kieran
39 WARREN-CLARK, Angie
40 WHITE, Helen Ione
41 O'CONNOR, Greg
42 LEWIS, Steph
43 WEBB, Duncan
44 SOSENE, Lemauga Lydia
45 WALKER, Janette
46 LORCK, Anna
47 UDANGA, Romy
48 BOYACK, Rachel
49 JOHAL, Sarb
50 CHEN, Naisi
51 HALBERT, Shanan
52 ROSEWARNE, Dan
53 AN, Jin
54 PABLA, Jesse
55 HUMPHREY, Hilary
56 SAVAGE, Tony John
57 LOADER, Brooke
58 SANDFORD, Ben
59 TAOGAGA, Kurt
60 WARREN, Heather
61 McDONALD, Sam
62 CHAPMAN, Cherie Joy
63 AL-BUSTANJI, Ala'
64 KAUR, Baljit
65 HIGGINS, Linsey
NA MANA
1 HARAWIRA, Hone
2 McNAB, Lisa
3 PAPALI'I, Papalii James
4 REPIA, Tracey-lee
NA MĀORI PARTY
1 FOX, Marama
2 FLAVELL, Te Ururoa
3 PAPA, Stanley Rahui
4 TAURIMA, Shane
5 REEDY-TAARE, Mei
6 TAMATI, Howie
7 TE HAU, Hinurewa
8 ESERA, Tuilagi Saipele
9 KIRIA, John
10 McLEOD, Te Waka
11 STODDART-SMITH, Carrie
12 LUA, Manase
13 KANG, Wetex
14 HOHAIA, Tasha
15 TOFILAU-TEVAGA, Esther
16 POROU, Tina Tangi Whaiora
17 NGATAI, Rongokino George
18 WHITLOCK, Cinnamon
19 BHANA, Raewyn Teresa
20 CHAPMAN, Ngārangi
21 BIDDLE, Wendy
22 MARSTERS, Maryanne
23 WILLIAMS, Karen
24 TE WHIU, Amiria
25 PEPA, Mele
26 TU'INUKUAFE, Tae Moala
NA NATIONAL PARTY
1 ENGLISH, Bill
2 BENNETT, Paula
3 CARTER, David
4 JOYCE, Steven
5 BROWNLEE, Gerry
6 BRIDGES, Simon
7 ADAMS, Amy
8 COLEMAN, Jonathan
9 FINLAYSON, Christopher
10 WOODHOUSE, Michael
11 TOLLEY, Anne
12 GUY, Nathan
13 KAYE, Nikki
14 McCLAY, Todd
15 SMITH, Nick
16 COLLINS, Judith
17 BARRY, Maggie
18 GOLDSMITH, Paul
19 UPSTON, Louise
20 NGARO, Alfred
21 MITCHELL, Mark
22 WAGNER, Nicky
23 DEAN, Jacqui
24 BENNETT, David
25 MACINDOE, Tim
26 SIMPSON, Scott
27 ROSS, Jami-Lee
28 KURIGER, Barbara
29 DOOCEY, Matt
30 HUDSON, Brett
31 LEE, Melissa
32 BAKSHI, Kanwaljit Singh
33 YANG, Jian
34 PARMAR, Parmjeet
35 YOUNG, Jonathan
36 HAYES, Jo
37 McKELVIE, Ian
38 O'CONNOR, Simon
39 BAYLY, Andrew
40 BISHOP, Chris
41 DOWIE, Sarah
42 KORAKO, Nuk
43 MULLER, Todd
44 PUGH, Maureen
45 RETI, Shane
46 SCOTT, Alastair
47 SMITH, Stuart
48 WILLIS, Nicola
49 LOHENI, Agnes
50 GARCIA, Paulo
51 KING, Matt
52 HIATT, David
53 GREGORY, Matt
54 PIERCE, Adrienne
55 ELLIOTT, David
56 BUNGARD, Katrina
57 BEERAM, Bala
58 O'FALLON, Carolyn
59 MURRELL, Euon
60 BROWN, Simeon
61 FALLOON, Andrew
62 HIPANGO, Harete
63 LEE, Denise
64 PENK, Chris
65 STANFORD, Erica
NA NEW ZEALAND FIRST PARTY
1 PETERS, Winston
2 MARK, Ron
3 MARTIN, Tracey
4 TABUTEAU, Fletcher
5 BALL, Darroch
6 MITCHELL, Clayton
7 PATTERSON, Mark
8 JONES, Shane
9 MARCROFT, Jenny
10 BINDRA, Mahesh
11 PARAONE, Pita
12 BOND, Ria
13 O'ROURKE, Denis
14 WILSON, David
15 PROSSER, Richard Ivor
16 REEVES, Jon
17 HUSBAND, Stu
18 FOSTER, Andy
19 MARK-SHADBOLT, Melanie
20 PETERSON, Helen
21 STEVENSON, Rob
22 CLOSE, Lisa Susan
23 ARBUCKLE, Jamie
24 HUBBARD, Josh
25 MEIKLE, Talani
26 CHAN, Peter
27 GRAY, Lester
28 DEGIA-PALA, Anne
29 KELLY, Suzanne
30 CHONG, Murray
31 FARRELLY, Jackie
32 GREENING, Toa
33 PAUL, Julian
34 WIHONGI, Shayne
35 RUDZKI, Romuald Edward
36 SKIPWORTH, Reginald Herbert
37 KAIRAU, Joe
38 KOLONI, Kym
39 MILLS, Geoffrey John
40 FAMILTON, Alex
41 ANDREWS, Anne-Marie
42 TILLEY, Julian
43 FLESHER, William
44 APANUI, Tane John
45 HALL, John
46 VOIGHT, Warren
47 JOHNSTON, Jane
48 EDWARDS, Frank
49 RUPPELDT, Ilja
50 PARORO, Mataroa
51 RUSHTON, Kerry Maria
52 GUPTA, Alok
53 LITTLEJOHN, Andrew McGregor
54 SARA, Susan
55 MAHON, Ken
56 PALMER, Lindy Michelle
NA NEW ZEALAND PEOPLE'S PARTY
1 NAUHRIA, Roshan
2 CHING, Steven
3 SHARMA, Anil
4 YAO, Lily
5 WU, Joann
6 NAMPALLY, Sree
NA NZ OUTDOORS PARTY
1 SIMMONS, Alan Frank
2 HAYNES, David
3 PAULL, Derrick
4 BEARMAN-RIEDEL, Wilf
NA THE OPPORTUNITIES PARTY (TOP)
1 MORGAN, Gareth
2 SIMMONS, Geoff
3 MOORE, Teresa
4 MIKAERE, Buddy
5 WILSON, Olly
6 POKERE-PHILLIPS, Donna
7 HILL, Doug
8 TUKAPUA, Piri-Hira
9 GLENJARMAN, Nicola
10 HAKA, Mika
11 SNOYINK, Nicky
12 WARWICK, Richard
13 JOHNSTON, Ted Faleauto
14 GRAY, Abe
15 ULYATT, Clint
16 THURSTON, Dan
17 IMMINK, Lesley
18 LEE, Vanessa
19 PLUNKET, Paddy
20 OWENS, Brittany
21 ISBISTER, Matt
22 HAY, David
23 CONDIE, Jenny
24 HAMMOND DOUBE, Jessica
25 NEILL, Kevin
26 SMITH, Lindsay
NA UNITED FUTURE
1 LIGHT, Damian
2 RICKARD, Ben
3 SHEFFIELD-CRANSTOUN, Kelleigh
4 NADAKUITAVUKI, Bale
5 TURNER, Judy
6 TODD, Quentin
7 HUBSCHER, John
8 FOSTER, John Truman
9 GASKIN, Ian Camden
10 WOOLSTON, JB
"
plst <- read.csv(text=listText, stringsAsFactors = FALSE, sep="\t")
plst <- plst %>% mutate(party = ifelse(is.na(number), person, NA)) %>% fill(party) %>%
filter(!is.na(number))
plst$let1st <- sapply(plst$person, function(x){utf8ToInt(strsplit(x, split="")[[1]][1])})
plst %>% filter(party %in% c("ACT NEW ZEALAND" ,
"GREEN PARTY",
"LABOUR PARTY",
"NATIONAL PARTY",
"NEW ZEALAND FIRST PARTY",
"THE OPPORTUNITIES PARTY (TOP)"
)) %>%
group_by(party) %>% mutate(overall_ranks = cummean(let1st)) %>% ungroup() %>%
ggplot(aes(x=number, y=let1st, colour=party)) + geom_smooth() + geom_point() +
xlim(1,20) + xlab("Party List Rank") + ylab("Surname (higher = later in alphabet")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment