Home
May 26, 2023 R / Shiny Data Analysis

2023 Turkish Election Simulator

Developing an R Shiny application to simulate D'Hondt seat distribution for the critical 2023 General Elections.

Update (2025)

I have rebuilt this tool using modern JavaScript for faster performance.

Try New Simulator →

In this blogpost I will talk about a software that I created using R Shiny. This software allows you to enter vote shares for parties that compete in 2023 Turkish General Elections for each electoral district. It then calculates the seat distribution using the D'Hondt method and creates a table for the seat distribution.

Context: The 2023 Election Systems

2023 General Elections in Turkey sparked a debate on the best way to enter the election for parties. First, the threshold was decreased to 7% but the alliance voting system—which allowed parties to benefit from the distribution of alliance votes—was removed. Following these changes, the discussion revolved around how smaller parties should enter the election and whether larger parties of the alliance can benefit from entering the election under a single ticket (entering under the most powerful party in that district) so that they will receive the most seats.

In People’s Alliance, HUDA-PAR and DSP entered the election under the incumbent AKP, and MHP entered the election as a party. In Nation Alliance, Gelecek, Deva, DP, and SP entered the election from CHP lists and IYIP entered on its own. The same issue was also discussed in Labour and Freedom Alliance where YSP and TIP entered under a general ticket in some districts but on their own in others. Turkey has 87 electoral districts with d’Hondt being used to allocate seats to parties in all of them.

The Simulator

Following this discussion, I developed a parliamentary election simulator for the 2023 Turkish National Elections. This application allows you to select a specific district and input the vote shares for different political parties. Using the D'Hondt method, the application calculates the allocation of seats for each party within that district.

You can access the original R-Shiny version here:
2023 Turkish Parliamentary Election Simulator (ShinyApps)

In this app, you can choose the electoral district that you would like to simulate. Changing the district will also change the total number of seats to be allocated as shown in the table on the right.

One positive aspect of this simulator is that you are able to enter either the vote share or the number of votes received, depending on your preference and the precision you would like.

Turkish Election Simulator Interface
Screenshot of the R Shiny Interface (2023)

Features

According to news sites in the 2018 elections, CHP won 35.78%, IYI won 12.5%, AKP won 29.57%, MHP won 10.58%, and HDP won 8.56% of the vote. We can enter these numbers into our simulator. When entering the vote shares you can notice two features: