ExportGenius Trade Analysis: Ukraine

Author

Gagan Atreya

Published

August 16, 2024

Tobacco imports

Code
rm(list = ls())

pacman::p_load(readxl, vtable, tidyverse, 
               lubridate, data.table, zoo, 
               readODS, patchwork, scales)


rm(list = ls())

df <- fread("/home/gagan/Desktop/soc_ace_2024/Ukraine-Imports-Tobacco.csv")

df$date <- dmy(df$Date)

df$date <- df$date
df$description <- df$`Product Description`
df$origin_country <- df$`Origin Country`

df$origin_country <- ifelse(df$origin_country == "Europiean Union", "European Union", 
                     ifelse(df$origin_country == "EUROPIEAN UNION", "European Union", df$origin_country))


df$supplier <- df$Supplier
df$importer <- df$Importer
df$price_invoice <- df$`Total Value USD`/df$Quantity
df$total_value <- df$`Total Value USD`

df <- df[, c("date", "description", "origin_country",
             "supplier", "importer", "price_invoice", "total_value")]

df02 <- fread("~/Desktop/soc_ace_2024/scripts/exportgenius/gold_analyses_latest/goldprice.csv")
df02$date <- ymd(df02$date)
df <- merge(df, df02, by = "date")
df$price_benchmark <- df$price_gram

#df[sapply(df, is.infinite)] <- NA

df <- df[!(df$price_invoice > 1000),]

plot01 <- ggplot(df, 
                 aes(x = date, 
                     y = total_value)) +
  geom_line() +
  geom_point() +  
  # ylim(15, 120) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  labs(title = "Ukraine Tobacco Imports", 
       x = "Date", 
       y = "Total Value") +  
  theme_bw() 

plot01

Code
plot02 <- df %>% 
  ggplot( aes(x = date, 
              y = total_value, 
              color = origin_country))+
  geom_line()+ 
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  
  geom_point()+
  labs(title = "Ukraine Tobacco Imports", 
       x = "Date", 
       y = "Total value")+
  theme_bw()

plot02

Code
plot03 <- df %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports by Origin", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot03

Code
max_price_index <- which.max(df$price_invoice)
# Remove the row with the highest value in the 'price' column
df <- df[-max_price_index, ]
df$filter01 <- ifelse(df$price_invoice > 150, 1, 0)
# table(df$filter01)
df <- df[df$price_invoice <=120, ]
df$price_difference <- df$price_invoice - df$price_benchmark

#df <- df[df$Origin_Country == "China", ]

df03 <- df[, c("date", "price_invoice", "price_benchmark")]

df_long <- reshape2::melt(df03, 
                          id.vars = "date", 
                          variable.name = "price_type", 
                          value.name = "price")

# ggplot(df_long, 
#        aes(x = date, 
#            y = price, 
#            linetype = price_type)) +
#   geom_line(size = 0.75, 
#             color = "black")+  
#   labs(title = "Ukraine Tobacco Imports", 
#        x = "Date", 
#        y = "Price") +  
#   theme_bw() 

df$price_difference <- df$price_invoice - df$price_benchmark

df$price_difference2 <- scale(df$price_difference)
df$price_benchmark2 <- scale(df$price_benchmark)

plot04 <- ggplot(df, aes(x = date, 
                         y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot04

Code
plot06 <- ggplot(df, aes(x = date, 
                         y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports by Importer: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) +
  facet_wrap(~importer, 
             ncol = 4)

plot06

Ukraine Tobacco Imports: Notable Origin Countries

Code
df11 <- df[df$origin_country %in% c("Azerbaijan", "European Union", "Kazakhstan",
                                    "Poland", "Switzerland", "Turkey", "Unknown") ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  facet_wrap(~origin_country, ncol = 2)+
  guides(color = FALSE) 

plot12

Armenia - Ukraine

Code
df11 <- df[df$origin_country == "Armenia", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Armenia", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Armenia: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Azerbaijan - Ukraine

Code
df11 <- df[df$origin_country == "Azerbaijan", ]


plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Azerbaijan", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                         y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Azerbaijan: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Brazil - Ukraine

Code
df11 <- df[df$origin_country == "Brazil", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Brazil", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()+
    scale_x_date(date_labels = "%b %Y", date_breaks = "2 months")

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Brazil: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) +
    scale_x_date(date_labels = "%b %Y", date_breaks = "2 months")

plot12

Croatia - Ukraine

Code
df11 <- df[df$origin_country == "Croatia", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Croatia", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Croatia: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Czechia - Ukraine

Code
df11 <- df[df$origin_country == "Czechia", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Czechia", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Czechia: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Denmark - Ukraine

Code
df11 <- df[df$origin_country == "Denmark", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Denmark", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Denmark: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

European Union - Ukraine

Code
df11 <- df[df$origin_country == "European Union", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: European Union", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from European Union: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Germany - Ukraine

Code
df11 <- df[df$origin_country == "Germany", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Germany", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Germany: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Kazakhstan - Ukraine

Code
df11 <- df[df$origin_country == "Kazakhstan", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Kazakhstan", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()+
    scale_x_date(date_labels = "%b %Y", date_breaks = "2 months")

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Kazakhstan: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) +
    scale_x_date(date_labels = "%b %Y", date_breaks = "2 months")

plot12

Mexico - Ukraine

Code
df11 <- df[df$origin_country == "Mexico", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Mexico", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()+
  scale_x_date(date_labels = "%b %Y", date_breaks = "2 months")

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Mexico: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) +
  scale_x_date(date_labels = "%b %Y", date_breaks = "2 months")

plot12

Poland - Ukraine

Code
df11 <- df[df$origin_country == "Poland", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Poland", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Poland: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Romania - Ukraine

Code
df11 <- df[df$origin_country == "Romania", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Romania", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Romania: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Switzerland - Ukraine

Code
df11 <- df[df$origin_country == "Switzerland", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Switzerland", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Switzerland: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Turkey - Ukraine

Code
df11 <- df[df$origin_country == "Turkey", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Turkey", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Turkey: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Unknown - Ukraine

Code
df11 <- df[df$origin_country == "Unknown", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~origin_country, ncol = 2)+
  labs(title = "Ukraine Tobacco Imports: Unknown", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Code
plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Ukraine Tobacco Imports from Unknown: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12