Collection Data From;

https://www.bps.go.id/id/statistics-table/2/MjE2MCMy/-metode-baru--aspek-indeks-demokrasi-indonesia--idi--menurut-provinsi.html

Create Data Frame;

democracythereeyears <- data.frame(
  Province = c("Aceh", "North Sumatera", "West Sumatera", "Riau", "Jambi", 
               "South Sumatera", "Bengkulu", "Lampung", "Bangka Belitung Island", 
               "Riau Island", "Special of Capital City Jakarta", "West Java", 
               "Central Tengah", "Special of Region Yogyakarta", "East Java", 
               "Banten", "Bali", "West Nusa Tenggara", "East Nusa Tenggara", 
               "West Kalimantan", "Centra Kalimantan", "South Kalimantan", 
               "East Kalimantan", "North Kalimantan", "North Sulawesi", 
               "Central Sulawesi", "South Sulawesi", "Southeast Sulawesi", 
               "Gorontalo", "West Sulawesi", "Maluku", "North Maluku", 
               "West Papua", "Papua"),
  `2023` = c(85.71, 83.12, 72.15, 79.39, 65.28, 80.94, 74.62, 73.79, 
             68.34, 79.72, 90.66, 87.97, 85.84, 77.76, 87.29, 83.11, 
             85.23, 64.49, 90.05, 92.16, 82.01, 81.4, 83.0, 84.59, 
             78.15, 87.11, 81.7, 71.72, 81.68, 74.87, 70.55, 65.58, 
             72.89, 79.98),
  `2022` = c(84.66, 87.66, 78.01, 84.46, 77.13, 86.78, 68.95, 79.9, 
             66.36, 88.34, 87.39, 90.61, 88.83, 87.35, 88.48, 83.8, 
             85.78, 76.75, 89.06, 91.35, 82.05, 80.7, 91.4, 77.93, 
             77.76, 81.69, 83.39, 87.49, 65.31, 67.78, 74.49, 70.84, 
             53.64, 67.23),
  `2021` = c(85.5, 88.51, 76.19, 88.4, 66.5, 85.08, 78.81, 76.64, 
             68.8, 90.91, 89.27, 89.71, 87.9, 74.31, 88.11, 82.26, 
             84.62, 77.41, 87.99, 81.15, 76.09, 70.13, 89.46, 82.78, 
             82.92, 92.76, 88.18, 79.28, 81.57, 67.24, 59.36, 80.61, 
             82.47, 75.64)
)

Data Interpretation;

The graph you produced shows the Indonesian Democracy Index (IDI) for each province from 2021 to 2023. This data comes from the Indonesian Democracy Index (IDI) and the Central Statistics Agency (BPS). West Sulawesi; This province experienced an increase in its IDI score from 2021 to 2023, with the green bar being longer than the orange and blue bars.West Papua; There was significant fluctuation with the green bar (2023) being longer than the blue bar (2021), but there was a decline in 2022. This graph helps provide an overview of how the level of democracy in various Indonesian provinces has changed over the past three years. This can be the basis for further analysis, for example to see what factors influenced the increase or decrease in the IDI score in a particular province.

Create Graph;

library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
fig <-plot_ly(democracythereeyears, x = ~X2021, y = ~Province, type = 'bar',
              name = '2021', orientation = 'h') %>%
  add_trace(x = ~X2022, name = '2022', orientation = 'h') %>%
  add_trace(x = ~X2023, name = '2023', orientation ='h') %>%
  layout(yaxis = list(title = 'Province'), xaxis = list(title = 'Index'),
         barmode = 'stack',
         title = list(text = "Index of Democracy in Indonesia 2021-2023",
                      x = 0.2,
                      pad =list(t = 5, b = 15)
                      ),
         margin = list(t = 34),
         height = 1000,
         autosize = TRUE
         )
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()
fig