Assignment 7

Author

Marko Kapranov

Сhange of population in Ukraine by oblasts

https://rpubs.com/mc_karadachi/1357436

As data for research were taken records made by Statistical service of Ukraine of 1989-2021 Total changes in population by oblasts

https://stat.gov.ua/en/explorer?md5=d2351a9ff28c2299bcfc9a14062eae99

Working with data

For the sake of visualisation, firsly, the shapefile was read and simplified to optimize the process of rendering map

country_sf <-  ms_simplify(read_sf("geoBoundaries-UKR-ADM1.shp"), keep = 0.1)

As the second step was taken processing the main data. Annual records were kept in wide format, consisting of column for each year and column that describe data. Since anything except for years and region column was not crucial to the data, only those columns were selected, and then sliced because of extra row that was depicting total image by country. Then to join shape file table and main data table, region names in shape file were formatted to main data type to join by those columns.

#| message: false
#| warning: false
data_df = read_csv('populus_data.csv') |>  select(-c(Indicator, Confidentiality, `Decimals displayed`, `Unit of measure`, `Scaling`, `Frequency`, `Timeseries notes`, `Observation notes`)) |> slice(1:28)
Rows: 28 Columns: 42
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (8): Indicator, Region, Frequency, Unit of measure, Scaling, Decimals d...
dbl (33): 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, ...
lgl  (1): Confidentiality

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
country_sf$shapeName <- c(
 "Khersonska",                "Volynska",                  "Rivnenska" ,                 "Zhytomyrska"  ,            
  "Kyivska" ,                  "Chernihivska"      ,        "Sumska"       ,            "Kharkivska"     ,          
  "Luhanska"    ,            "Donetska"   ,             "Zaporizka"  ,           "Lvivska"      ,            
 "Ivano-Frankivska"    ,    "Zakarpatska"      ,      "Ternopilska"      ,         "Chernivetska"    ,        
 "Odeska"    ,             "Mykolaivska"      ,         "Avtonomna Respublika Krym", "Vinnytska"     ,        
 "Khmelnytska"  ,         "Cherkaska"   ,            "Poltavska"   ,             "Dnipropetrovska" ,       
 "Kirovohradska"   ,          "Kyiv"      ,                    "Sevastopol"  )

After processing base tables they were merged by region names, and pivoted into longer format to make compelling dynamic map in which each frame represented state of data by year.

joined_table <- right_join(data_df[data_df$Region != "Ukraine",], country_sf, by = c("Region" = "shapeName")) |>
  pivot_longer(cols = `1989`:`2021`,
    names_to = "year",
    values_to = "value" ) |> 
  mutate(year =as.numeric(year) )

Visualisation

To efficiently represent data that was processed earlier, was decided to make an animation that could show state of ukraines population in each year.

ukraine_mig <- ggplot(joined_table) +
  geom_sf( aes(geometry = geometry, fill = value)) + transition_time(year) +
      ease_aes('linear') + theme_void() +
  theme(
    plot.margin = margin(0, 0, 0, 0),
    legend.position = "left",
    aspect.ratio = 0.55
  )  + labs (fill = "Change in population", title = "Change in Population by oblasts, {as.integer(frame_time)}") + scale_fill_gradient2(low = "darkred", high = "darkgreen", mid = "white") 

animate(ukraine_mig, duration = 25, fps = 15)

Conclusion

Based on the received chart, it is seen that in Ukraine, a negative trend is leading in the population rate, which means that the number of people is gradually declining. From 1989 to 1992 average rate was positive, being around +5000, with the highest growth in Crimea. Then it sharply fell in all regions and continued to decline until 2008, reaching bottom at 2000, and the peak of decline was mainly located in the eastern regions, then eventually and slowly it began to recover towards a neutral rate by 2012. The only administrative unit that was growing in population was Kyiv, whose growth started in 2001 and hasn’t ended since, due to its status of the capital. After 2012, Regions experienced another decrease in population, which lasted until the last recorded year, and yet again, the only administrative units that had an increase in population were Kyiv and Kyiv oblast, whose soaring population began in 2015