output: html_document: fig_width: 30 fig_height: 10 pdf_document: default word_document: default editor_options: chunk_output_type: inline

Title: “Assignment 2” subtitle: “Deconstruct, Reconstruct Web Report” author: “Sebestian P N Dissanayake (Student Number:s3912761”)" output: html_document urlcolor: blue

Original

  1. Problematic data visualization URL:

https://howmuch.net/articles/us-exports-imports-of-goods-and-services-by-type-of-product

  1. Problematic data visualization image: Note: This Visualization refers to “Exports of Goods & Services by Type of Product”

Source: Howmuch.net website Section (2021).


Objective

The Objective of the Original visualization is to depict the exports by product in USA in the year 2020. This visualization provides product level information to the viewer. The targeted audience primarily consists of parties interested in understanding the import and export landscape of the US economy and in particular what products and services America is producing in excess and what products and service America heavily relies from other nations as Imports.

It is also imperative to note that the audience can be any layperson without international trade knowledge or with expertise and exposure to various data visualizations methods.(The website is publicly accessible without the need for any subscriptions or authenticated logins)

The data source for this visualization is from the U.S. Bureau of Economic Analysis (http://apps.bea.gov/iTable/iTable.cfm?reqid=19&step=2#reqid=19&step=2&isuri=1&1921=survey) and can be considered reliable and accurate.

The visualization chosen had the following three main issues:

(1) Failure to provide answers within a quick glance at the viz. At a quick glance, there is no information to find the highest export product, or lowest export product by comparative assessment, which is how the human brain operates. human brain is good at digesting comparative measures when compared against a common scale. This visualization fails in that aspect.

(2) color issues - (colors that has no link to its use) Color usage does not help the end user. After a while, exports and services can be distinguished by the use of color.Apart from that, there is no clear indication of what each color represents.

(3) Overall visualization looks more scientific and complex, and chaotic (visual bombardment). The usage of icons in this visualization are hard to understand and overly used, in fact the use of these icons defeats the purpose, because icons are used to assist human brain to quickly understand in a shorter period of time. Also, Public users may be shunned away due to its complex overall visualization which resembles more in the line of nuclear and scientific presentations.

Reference

Howmuch.net article https://howmuch.net/articles/us-exports-imports-of-goods-and-services-by-type-of-product. Retrieved on 27 June 2021 from Howmuch.net website.

Code

The following code was used to fix the issues identified in the original.

# install.packages("plotly")
# install.packages("treemap")
# install.packages("writexl")
# 
# install.packages("remotes")
# remotes::install_github("d3treeR/d3treeR")
# install.packages("d3treeR")
# install.packages("googleVis")
# install.packages("viridis")
# install.packages("hrbrthemes")


# Load packages 
library(readr) 
library(readxl) 
library(openxlsx) 
library(dplyr)
library(plotly)
library(treemap)
library(d3treeR)
library(htmltools)
library(viridis)
library(hrbrthemes)
library(ggplot2)
library(tinytex)

  
impexp_df1 <- read.xlsx("C:/Users/niles/Documents/RMIT - Post Graduate studies Applied Analytics/MODULE2-VIS AND COMM/america import and export by product.xlsx", sheet = 2)
#exp_2020 <- impexp_df1 %>% filter(impexp_df1$Trade.Type.Broad == "EXPORT" & impexp_df1$Year =="2020" & !is.na(impexp_df1$Color)) 
exp_2020 <- impexp_df1 %>% filter(impexp_df1$Trade.Type.Broad == "EXPORT" & impexp_df1$Year =="2020" & impexp_df1$Color<5) 
exp_2020_tot <- impexp_df1 %>% filter(impexp_df1$Trade.Type.Broad == "EXPORT" & impexp_df1$Year =="2020" & impexp_df1$Color>5) 
exp_2020 <- exp_2020[order(exp_2020$Total),]
exp_2020_tot<- exp_2020_tot[order(exp_2020_tot$Total),]


  # Us Export (2020) Product and Service     
US_EXP_PROD <-ggplot(exp_2020, aes(x=Total,y=Description, fill=Tier)) + 
    geom_bar(width=0.4,position="dodge", stat="identity")+
      theme(axis.text=element_text(size=16, face="bold"))+
 # scale_x_continuous(breaks = NULL)+
    #geom_text(aes(label = Total), vjust = .5, colour = "white", size=2.9,position = position_dodge(width=.1))+
    geom_text(aes(label = Total) ,hjust = -0.1, size=5.1, fontface=2)+
   #  geom_text(aes(label = paste0("$"Total,"B")),hjust = -0.1, size=3.9, fontface=2)+
  #geom_label( label=rownames(exp_2020$Total), nudge_x = 0.25, nudge_y = 0.25, check_overlap = T ) +
    scale_fill_viridis(discrete = T, option = "E") +
    ggtitle("US.Exports by product in 2020") +
    facet_wrap(~Trade.type) +
      theme(strip.text.x = element_text(size = 20,  angle = 0))+
    theme(plot.title = element_text(size = 40, face = "bold"))+
  theme(legend.title = element_text(face = "bold"))+
  #theme_ipsum() +
  #  theme_minimal() +
   # theme(legend.position="none") +
   xlab("[Billions of Dollars], seasonally Adjusted at annual Rates")



  # Us Export (2020) TOtals 
US_EXP_TOT <- ggplot(exp_2020_tot, aes(x=Total,y=Description, fill=Tier)) + 
    geom_bar(width=0.4,position="dodge", stat="identity")+
    theme(axis.text=element_text(size=16, face="bold"))+
  scale_x_continuous(breaks = NULL)+
    #geom_text(aes(label = Total), vjust = .5, colour = "white", size=2.9,position = position_dodge(width=.1))+
   geom_text(aes(label = Total) ,vjust = 0.3,colour = "white", size=5.9, fontface=2)+
   #  geom_text(aes(label = paste0("$"Total,"B")),hjust = -0.1, size=3.9, fontface=2)+
    geom_label(aes(label =Total), colour = "grey", size=5,fontface = "bold") +
  #geom_label( label=rownames(exp_2020$Total), nudge_x = 0.25, nudge_y = 0.25, check_overlap = T ) +
    scale_fill_viridis(discrete = T, option = "E") +
  #  scale_color_manual(labels = c("T999", "T888"), values = c("blue", "red")) +
    ggtitle("Total US.Exports by product in 2020") +
    facet_wrap(~Trade.type) +
      theme(strip.text.x = element_text(size = 17,  angle = 0))+
    theme(plot.title = element_text(size = 40, face = "bold"))+
  #theme_ipsum() +
  #  theme_minimal() +
   # theme(legend.position="none") +
    xlab("[Billions of Dollars], seasonally Adjusted at annual Rates")+
theme(axis.text.x = element_text(angle = 90, size=3.9,vjust = 0.5, hjust=1))

Data Reference

Data website URL: U.S. Bureau of Economic Analysis (http://apps.bea.gov/iTable/iTable.cfm?reqid=19&step=2#reqid=19&step=2&isuri=1&1921=survey) Link to Data: https://apps.bea.gov/iTable/iTable.cfm?reqid=19&step=3&isuri=1&nipa_table_list=133&categories=survey

Data Retrieved: 26 June 2021 ** Note: Data is refreshed periodically. Last Revised on: July 29, 2021 - Next Release Date August 26, 2021

Reconstruction

The following 2 plot fixes the main issues in the original.

# Us Export (2020) Product and Service  
US_EXP_PROD

# Us Export (2020) TOtals 
US_EXP_TOT

Website research for problematic viz and R Coding

https://stackoverflow.com/questions/23161897/how-to-change-labels-legends-in-ggplot https://stackoverflow.com/questions/52375548/how-to-group-in-ggplot-geom-bar-r https://stackoverflow.com/questions/40833809/add-legend-to-geom-line-graph-in-r https://stackoverflow.com/questions/40211451/geom-text-how-to-position-the-text-on-bar-as-i-want https://statisticsglobe.com/add-count-labels-on-top-of-ggplot2-barchart-in-r https://www.rdocumentation.org/packages/viridis/versions/0.6.1/topics/scale_fill_viridis https://www.r-graph-gallery.com/barplot.html https://stackoverflow.com/questions/5208679/order-bars-in-ggplot2-bar-graph https://tidyverse.github.io/ggplot2-docs/reference/geom_text.html#geom-label https://plotly.com/r/horizontal-bar-charts/ https://www.r-bloggers.com/2017/06/bar-plots-and-modern-alternatives/ https://www.trade.gov/data-visualization/state-economy-and-trade-factsheets https://www.r-graph-gallery.com/barplot.html https://www.r-graph-gallery.com/interactive-charts.html https://plotly.com/r/bar-charts/#customizing-bar-color https://github.com/d3treeR/d3treeR/issues/10 https://www.storytellingwithdata.com/blog/2018/6/5/an-alternative-to-treemaps https://www.google.com.au/search?q=treemap+with+percentage+R&tbm=isch&ved=2ahUKEwj5mfagl4byAhVJMnIKHWqOBvEQ2-cCegQIABAA&oq=treemap+with+percentage+R&gs_lcp=CgNpbWcQA1CJ9xtY6P4bYL-CHGgAcAB4AIABqAGIAZoGkgEDMC41mAEAoAEBqgELZ3dzLXdpei1pbWfAAQE&sclient=img&ei=SoUBYfnMJMnkyAPqnJqIDw&bih=664&biw=1536#imgrc=NgAs85FrLaenPM https://www.r-bloggers.com/2018/09/simple-steps-to-create-treemap-in-r/ https://rpubs.com/brandonkopp/creating-a-treemap-in-r https://oec.world/en/visualize/tree_map/hs92/export/usa/all/show/2019/ https://r4ds.had.co.nz/graphics-for-communication.html https://atlas.cid.harvard.edu/explore?country=231&product=undefined&year=2019&productClass=HS&target=Product&partner=undefined&startYear=1995 https://public.tableau.com/views/Climate-RelatedDevelopmentFinanceRecipient2019/CRDFRP?:language=en-US&:display_count=n&:origin=viz_share_link&:showVizHome=no#1 https://www.oecd.org/dac/financing-sustainable-development/datavisualisations/ https://plotly.com/r/bar-charts/ https://wits.worldbank.org/trade-visualization.aspx https://playground.anychart.com/gallery/src/Maps_Connectors/Top_Chinese_Exports_to_the_World https://www.anychart.com/products/anymap/gallery/Maps_Connectors/Top_Chinese_Exports_to_the_World.php http://www.fao.org/faostat/en/#data/TCL/visualize http://www.fao.org/faostat/en/#home https://datavizcatalogue.com/methods/connection_map.html https://internationaleducation.gov.au/research/datavisualisations/Pages/pathways.aspx https://internationaleducation.gov.au/research/international-student-data/pages/default.aspx https://www.uicc.org/news/globocan-2020-new-global-cancer-data https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(18)30324-0/fulltext https://flowingdata.com/