leedrake5 / Russia-Ukraine

Equipment Loss Tracking
MIT License
617 stars 26 forks source link

Not really an issue, just sharing #1

Closed Vithar42 closed 2 years ago

Vithar42 commented 2 years ago

First, thanks for including the code and data on your post, I wish everyone would do that.

Took your code, tweaked it a little to answered a question a few people asked in the reddit thread. Do with it as you like.

Additional libraries needed:

library(tidyverse)
library(lubridate)
library(scales)
### Percent Loss estimate per common request
### Total Tanks sourced from https://inews.co.uk/news/world/russia-tanks-how-many-putin-armoured-forces-ukraine-nato-explained-1504470
current_percent_tanks <- equipment_losses  %>%
  select(Date, Russia = Russia_Total, Ukraine = Ukraine_Total) %>%
  mutate(Date = mdy(Date),
         RT = 13300 - Russia,
         UT = 2100 - Ukraine,
         Russia =  Russia / RT,
         Ukraine = Ukraine / UT) %>%
  pivot_longer(cols = c("Russia", "Ukraine"),
               names_to = "Country",
               values_to = "Total") %>%
  ggplot(aes(Date, Total, colour=Country, shape=Country)) +
  geom_point() +
  stat_smooth() +
  scale_x_date(date_labels = "%m/%d") +
  scale_y_continuous(labels = percent) +
  labs(y = "Total Equipment Losses [% of tanks]") +
  ggtitle(paste0("Total equipment losses through ", Sys.Date())) +
  theme_light()

ggsave("current_percent_tanks.jpg", current_percent_tanks, device="jpg", width=6, height=5)
leedrake5 commented 2 years ago

Thanks @Vithar42! I've integrated this code for Tanks and AFVs. Will do the same for other unit types. Note that I did it dynamically - I factor captures by Russian and Ukrainian forces respectively.