1  Preprocessed Data

Author

Group Yellow Submarine

Published

November 16, 2023

1.1 Yellow Submarine’s Project Proposal on WITS data

The choice of this domain stems from the significance of Turkey’s role in the global trade landscape between 2002-2020. Before settling on the WITS database, we reviewed existing solutions, including the Harvard University Atlas project and Visualizations from the Observatory of Economic Complexity.)

We have decided on this database considering the primary sources that include:

a. Exports&Imports: Analyze composition of exports and imports data by complexity for each commodity

b. Trade Partnerships: Utilize international trade databases to identify Turkey’s major trade partner and assess trade volumes

c. Additional Insights: Explore supplementary datasets as needed to uncover specific aspects of Turkey’s trade dynamics, such as tariffs and distances data to map out key trading routes, highlighting the connectivity and strategic importance of Turkey in global trade.

With this project, we aim to produce a comprehensive report that synthesizes the findings into a coherent narrative. Visualizations, charts, and infographics will be employed to enhance the accessibility of the data.

1.2 Dataset Installation and Preprocessing

1.2.1 Necessary Source Packages

library(tidyverse)
Warning: package 'dplyr' was built under R version 4.3.2
Warning: package 'stringr' was built under R version 4.3.2
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dplyr)
library(ggplot2)
library(tradestatistics)
Warning: package 'tradestatistics' was built under R version 4.3.2
library(tibble)

1.2.2 Datasets

The data retrieval and table creation were facilitated using the ‘tradestatistics’ package developed by a group of developers led by Mauricio Vargas. This package streamlines the process of fetching data from api.tradestatistics.io and generates tables that are convenient for analytical purposes. We used otc_create_tidy_data for our analysis

DataSet 1: This data set shows Turkey’s export and import values with product categories & related commodities’ names & codes only

DataSet 2: This data set shows Turkey’s and its partners’ export and import values with product categories & related commodities’ names & codes

#DataSet 1: 

wits_turkey_data_only <- ots_create_tidy_data(
  years = 2002:2020,
  reporters = "tur",
  table = "yrc"
)
head(wits_turkey_data_only)

#DataSet 2: 

wits_turkey_data_with_partners <- ots_create_tidy_data(
  years = 2002:2020,
  reporters = "tur",
  table = "yrpc"
)
head(wits_turkey_data_with_partners)

#Combine the datasets into a list
combined_datasets <- list(
  wits_turkey_data_only = wits_turkey_data_only,
  wits_turkey_data_with_partners = wits_turkey_data_with_partners
)

1.3 Creating RDS file

saveRDS(combined_datasets, file = "wits_data.rds")

The created .Rdata file can be reached through RDS Link

1.4 Monitoring the Data

library(DT)
Warning: package 'DT' was built under R version 4.3.2
loaded_datasets <- readRDS("wits_data.rds")
read_wits_turkey_data_only <- loaded_datasets$wits_turkey_data_only
read_wits_turkey_data_with_partners <- loaded_datasets$wits_turkey_data_with_partners

DT::datatable(head(read_wits_turkey_data_only),editable = list(
  target = 'row', disable = list(columns = c(1, 3, 4))
))
DT::datatable(head(read_wits_turkey_data_with_partners), editable = list(
  target = 'row', disable = list(columns = c(1, 3, 4))
))

1.5 References

Basic examples listed in this link were useful during creating RDS and monitoring data tables