Examining Trade in Merchandise Using R

Posted on Nov 30, 2018


The purpose of this shiny app was to allow users to examine trade in merchandise information on a country-by-country basis.

You can find the app here and the code used to implement the app here.

The Data:

The dataset used was downloaded from the World Trade Organization's (WTO) website here. The dataset focuses on merchandise trade within a country. Some of the variables in the dataset include:

  • Country
  • Year
  • Category of trade
  • Whether the trade was an export or import
  • The amount traded, in millions USD.

For ease of use, the data were constrained to 2015, and the categories of trade were derived from the nine major categories listed by the WTO here.

How to use the App:

After the app loads, you will be presented with a world map. This is the first of four page tabs. From there, you can switch to the other tabs "Country A", "Country B", and "Comparisons" by clicking on them.

Below the page tabs, there are two dropdown menus: "USD or Percentage of Trade" and "Flow of Trade". These two menus will transform what the map shows. In the picture above, Percentage of Trade and Exports are selected. In this case, the map shows the percentage of each country's trade that is exports. The darker shade of green, the higher the percentage of exports is for that particular country.

Under the second tab "Country A", you can examine an individual country's trade in merchandise. Countries can also be selected from the dropdown menus below the page tabs. (Because the lists contain over 200 countries, it is recommended that you type in the country you are interested in to ease the country selection process.) In the picture above, China was selected as Country A, and both Import and Exports (All) are included. This allows you to examine categories of Chinese trade in a bar graph. If you are interested in specific values, simply move the cursor over any bar to show the exact values.

At the bottom of the page, there is a series of bar graphs that compare each merchandise category to the world average for that category. On the sidebar, there are nine checkboxes. The default is to show nine graphs, one for each category. However, because China does not trade in Agricultural Products, Other Manufactures, and Other Semi-Manufactures, these checkboxes can be used to limit the merchandise categories shown. Graphs will be added or removed accordingly.

The "Country B" tab functions exactly the same as the "Country A" tab, but it is controlled by the Country B dropdown menu.

The final page tab "Comparison" is a comparison of the percentage of trade between the two selected countries. (The selected countries are those selected using the Country A and Country B dropdown menus.) In the above photo, China and the United States are shown.  To compare different countries, simply select different countries using the Country A and Country B dropdown menus on the sidebar.

At the bottom of "Comparisons" page, there is a series of bar graphs that compare each merchandise category of Country A to each merchandise category of Country B. Feel free to click around and see how it works!

Future Directions:

  • The code that runs the data needs to be cleaned. There is a lot of code that can be simplified/removed.
  • The data could include more than just one year. This will allow for the examination of longitudinal trends.
  • The WTO website has a far greater and more in-depth dataset that includes transactions between countries. However the data are not well-structured and would take hours to clean properly.

About Author

Devon Blumenthal

Prior to joining NYC Data Science Academy, Devon received his Masters in Measurement, Statistics, and Evaluation at the University of Maryland, College Park. As an instructor, he taught Introduction to Statistics and as a teaching assistant, he helped...
View all posts by Devon Blumenthal >

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp