Exploring Korean Trade Data on kdiplo R Package

Trade Dependence with China

Korea
Korean dataset
dataset
R
R package
diplomacy
kdiplo
kdata
kdiploviz
kdataviz
Author

Kadir Jun Ayhan

Published

Tuesday, April 23, 2024

Since the foundation of the Republic of Korea in 1948, the economy has been one of the two pillars of Korean diplomacy, alongside security.1 Indeed, the country’s trade has virtually always been over 50% of its GDP since 1970s, reaching over 100% in 2010s (see Figure 1).

1 Korea added “public diplomacy” as a third pillar of diplomacy in 2010.

Show the code
##| label: fig-trade_gdp
##| fig-cap: Trade as % of GDP in Korea

trade_gdp <- WDI::WDI(indicator = c("trade_gdp" = "NE.TRD.GNFS.ZS",
                                    "gdp_growth" = "NY.GDP.MKTP.KD.ZG"),
                      country = "KOR",
                      start = 1960, end = 2022)

trade_gdp %>% ggplot(aes(year, trade_gdp)) +
  geom_line(color = "#2780e3") +
  scale_x_continuous(breaks = seq(1960, 2022, 5)) +
  # add percentages to y axis
  scale_y_continuous(labels = scales::percent_format(scale = 1)) +
  labs(#title = "Trade as % of GDP in Korea",
       x = "Year",
       y = "Trade as % of GDP") +
  ggthemes::theme_pander() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))
Figure 1: Trade as % of GDP in Korea

Source: WDI

Therefore, Korea’s trade constitute an important data source for studies on Korean diplomacy. In this blog post, I will explore the trade data in the kdiplo R package. There are two main sources for the data.

  1. Korean Statistical Information Service (KOSIS) which has Korea’s trade data from 1965 until 2023 with countries and regions.

  2. Correlates of War (COW)’s Trade Data v4.0 which Korea’s trade data from 1949 until 2014.

In the trade data in the kdiplo package, I share both sets of data (export_kosis and import_kosis referring to export and import data from KOSIS; export_cow and import_cow referring to export and import data from COW) as well as mutated export and import variables that rely mainly on KOSIS data, but imputing it with the COW data where the former is missing. While in my own research, I use other ways to impute the still missing data, in the kdiplo package, I don’t do that, leaving it to the users’ discretion.

Let’s explore Korea’s trade data in the kdiplo package.

I have not yet created a function to get the data from the package, but one can simply get the data and assign it to an object. This is what the dataset looks like:

Show the code
trade <- kdiplo::trade_data

glimpse(trade)
Rows: 16,511
Columns: 18
$ iso3c                  <chr> "ABW", "ABW", "ABW", "ABW", "ABW", "ABW", "ABW"…
$ country                <chr> "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "A…
$ year                   <dbl> 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972,…
$ export                 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ import                 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ total_export           <dbl> 175082000, 250334000, 320229000, 455400000, 622…
$ total_import           <dbl> 463442000, 716441000, 996246000, 1462873000, 18…
$ export_kosis           <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ import_kosis           <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ export_cow             <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ import_cow             <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ index                  <dbl> 52.9, 54.4, 56.1, 58.3, 60.9, 63.9, 66.7, 68.7,…
$ cpi                    <dbl> 0.1516194, 0.1559186, 0.1607911, 0.1670966, 0.1…
$ export_cons_2015       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ import_cons_2015       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ total_export_cons_2015 <dbl> 1154746877, 1605542879, 1991584636, 2725369811,…
$ total_import_cons_2015 <dbl> 3056614628, 4594968105, 6195904267, 8754655055,…
$ updated_at             <date> 2024-04-27, 2024-04-27, 2024-04-27, 2024-04-27…

Trade Dependence

We live at an age of increasing great power rivalry in the Indo-Pacific region, even this relatively new geopolitical naming of the region causing controversies with China. For quite a long time, region’s two great powers, China and Japan, outsourced great power management to the United States and ASEAN. However, in recent years with growing assertiveness of Chinese foreign policy and the US’s pivot to Asia, the region has seen the rise of US-centric minilateralisms that one way or another encircle China. For long, Korea, despite its iron-clad alliance with the US, has not taken an active part in most of these minilateralisms to avoid antagonizing China. Often two reasons are cited for this: 1) Korea’s economic dependence on China, and 2) China’s influence on North Korea, hence Korean Peninsula.

Let’s visualize Korea’s trade dependence over time.

Show the code
trade %<>% mutate(trade_dep = trade / total_trade_group_by,
                  label = ifelse(year == max(year), iso3c, NA))


trade %>% filter(iso3c %in% c("JPN", "CHN", "USA", "VNM")) %>% #, "SAU", "HKG", "TWN")) %>%
  ggplot(aes(year, trade_dep, color = iso3c)) +
  geom_line() +
  geom_label_repel(aes(label = label), nudge_x = 8, size = 8) +
  scale_x_continuous(breaks = c(seq(1948, 2023, 10), 2023)) +
  scale_y_continuous(breaks = seq(0, 1, 0.1), labels = scales::percent_format(scale = 100)) +
  labs(#title = "Trade Dependence of Korea",
       x = "Year",
       y = "Share in Korea's Trade Volume") +
  ggthemes::theme_pander() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  theme(legend.position = "none")
Figure 4: Korea’s Trade Dependence with China, US, Japan, and Vietnam

China has surpassed Japan and the United States as Korea’s largest trading partner since the mid-2000s. Before COVID-19, China’s share in Korea’s trade reached 25%, declining since then to just above 20%, but still remaining as the largest trading partner. The US’s share in Korea’s trade is around 15%, while Japan and Vietnam’s share has been 6% each. The following is the ranking of Korea’s trading partners since its foundation. Below, I visualize the rankings of Korea’s trading partners over time.

Show the code
# give trade data countries rankings based on trade_dep.

trade_decade <- trade %>% 
  mutate(decade = floor(year / 10) * 10)

trade_decade %<>% group_by(iso3c, decade) %>%
  summarise(trade_dep_decade = mean(trade_dep, na.rm = TRUE), .groups = 'drop')
  
trade_decade %<>% 
  group_by(decade) %>%
  arrange(decade, desc(trade_dep_decade)) %>%
  mutate(rank = row_number()) %>%
  ungroup()


top10 <- trade_decade %>% filter(decade == 2020) %>%
  top_n(-10, rank) %>%
  pull(iso3c)

first_appearance <- trade_decade %>%
  filter(iso3c %in% top10) %>%
  group_by(iso3c) %>%
  summarise(first_decade = min(decade[rank < 11])) %>%
  ungroup()

# Join this back to the original data to identify where to place labels
label_data <- trade_decade %>%
  inner_join(first_appearance, by = "iso3c") %>%
  filter(decade == first_decade)


# using ggbump to visualize the rankings of trade partners over time.

trade_decade %>% filter(iso3c %in% top10) %>%
  ggplot(aes(decade, rank, color = iso3c)) +
  ggthemes::theme_clean() +
  scale_x_continuous(limits = c(1935, 2025)) +
  scale_y_continuous(limits = c(1, 10), breaks = seq(1, 10, 1)) +
   geom_bump(size = 1.5) +
  geom_point(size = 6) +
  geom_text(data = label_data,
            aes(decade = decade - 0.1, label = iso3c),
            size = 5, hjust = 1.3) +
  geom_text(data = trade_decade %>% filter(iso3c %in% top10 & decade == max(decade)),
            aes(decade = decade + 0.1, label = iso3c),
            size = 5, hjust = -0.3) +
  scale_color_brewer(palette = "RdBu") +
  theme(legend.position = "none") +
  labs(title = "Ranking of Korea's Trading Partners",
       x = "Year",
       y = "Rank")

ggsave("trade_ranking.png", width = 10, height = 6, dpi = 300)
Figure 5: Ranking of Korea’s Trading Partners: 1940s to 2020s

Concluding Remarks

Korea’s trade data is an important source for studies on Korean diplomacy, helping us understand trends and tendencies in Korean foreign policy. In this blog post, I explored the trade data in the kdiplo R package. I visualized the trade volume, Korea’s trade dependence, and the rankings of Korea’s trading partners over time. The data is available in the kdiplo package. In a future blog post, I will explore Korea’s economic diplomacy bringing together the trade data with my other data on Korean presidents’ bilateral diplomatic visits. Feel free to add comments next to this blog post, or make requests using the issues tab in the kdiplo package’s Github.

In line with my post here, I invite you to explore and interact with this data. Let’s craft stories together using these datasets and connect through hashtags #kdiplo, #kdiploviz, #kdata, and #kdataviz.