I am looking for a practical guide/tutorial preferably in R to show how to do gerrymandering. (I was looking for it also in CRAN but didn't find such package) Gerrymandering is the manipulation of the boundaries of electorial districts in order to gain political advantage for one party. If there is an analogy/similar process in another area it would be also interesting.

I have detailed historical election results. I can see the results from each "voting office" and also the geographical area they cover. These results are aggregated to electorial district level. I'd like to see how moving voting offices to different electorial districts can influence the results of the election and how this process can be optimized for one party. Certainly there should be some constraints not to create really weird shaped districts at the end.

  • $\begingroup$ Regarding your last sentence, it depends on your definition of "really weird". The origin of the word refers to the salamander-like shape of the resulting district. So you will have to balance optimization with constraints because the more geometric constraints you impose, the less optimized the result will be. $\endgroup$
    – bogatron
    Commented May 21, 2015 at 16:24
  • $\begingroup$ You are right @bogatron. But I know that there are certain statistical formulas to measure the compactness of a shape. Ideally this could be involved also in the optimization process. $\endgroup$
    – Viktor
    Commented May 21, 2015 at 16:32
  • $\begingroup$ try gis.stackexchange.com people there may have a better idea or some experience with redistricting. $\endgroup$
    – Spacedman
    Commented May 21, 2015 at 20:53

1 Answer 1


I found a number of interesting articles on mathematical analyses of gerrymandering. Hopefully some of these might give you some ideas on detecting / optimising against gerrymander.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.