Taking stock of anti-dumping measures

Download data from wto

tf <- tempfile()
##download.file("https://trade-remedies.wto.org/en/antidumping/measures/download/eyJpbml0WWVhcnMiOltdLCJpbkZvcmNlRnJvbVllYXJzIjpbXSwicmVwb3J0aW5nTWVtYmVycyI6W10sImV4cG9ydGluZ01lbWJlcnMiOltdLCJoc1NlY3Rpb25zIjpbXSwiaW5Gb3JjZSI6ImFsbCJ9", tf)
tf <- "~/Downloads/anti-dumping-measures.xlsx"

Read data

ad <- readxl::read_excel(tf)|>
  ## nice names!
  janitor::clean_names()
names(ad)
##  [1] "measure_in_force_from"  "measure_in_force_until" "in_force"              
##  [4] "investigation_number"   "initiation_date"        "reporting_member"      
##  [7] "exporting_member"       "subject_product"        "hs_section_code"       
## [10] "hs_section_label"

Create function to get the in force measures by date

h <- function(x, date) x|>
  ## ended after date (or ending date is missing)
  filter(is.na(measure_in_force_until)|(measure_in_force_until>=date))|>
  ## started before date
  filter(measure_in_force_from<=date)

Get count by exporter/reporter pairs

ad_stock <- purrr::map_dfr(
  seq.Date(as.Date("2003-07-01"), Sys.Date(), by = "year"),
  ~h(ad, date=.x)|>
    group_by(reporting_member, exporting_member)|>
    summarise(date=.x, n=n(), n_hs_sections=length(unique(hs_section_code)), .groups="drop"))

Antidumping measures in force by reporting country on 2022-07-01

top5 <- ad_stock|>
  filter(date==max(date))%>%
  group_by(reporting_member)%>%
  summarise(n=sum(n))%>%
  arrange(-n)%>%
  head(5)
top5%>%
  knitr::kable()
reporting_member n
United States 492
India 160
Brazil 136
Türkiye 129
China 121

Plot it

library(geomtextpath)
## Loading required package: ggplot2
ggplot(aes(x=date, y=n,
           color=reporting_member, label=reporting_member),
       data=ad_stock%>%
         group_by(date, reporting_member)%>%
         summarise(n=sum(n))%>%
         filter(reporting_member%in%top5$reporting_member)) +
  theme_dark() +
  labs(x="", y="Anti-dumping measures in force", title = "Measures against all exporting countries, by reporting country", color="Reporting member") +
  geom_textline(size=4) +
  guides(color="none") +
  theme(panel.background=element_rect(fill = "grey10",
                                      colour = NA))
## `summarise()` has grouped output by 'date'. You can override using the
## `.groups` argument.