<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/introducing-the-new-zealand-trade-intelligence-dashboard/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://nzprimarysectortrade.wordpress.com/2018/10/15/introducing-the-new-zealand-trade-intelligence-dashboard/"> R related – Project R</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I’d like to introduce to you the <a rel="nofollow" href="http://tradeintelligence.mbie.govt.nz/" target="_blank">New Zealand Trade Intelligence Dashboard</a>. This is one of the New Zealand government shiny web apps that should have been mentioned in <a rel="nofollow" href="http://freerangestats.info/blog/2018/05/13/nz-govt-shinyapps" target="_blank">Peter Ellis’ post</a>. If you are only interested in TRADE, you may go to ‘Commodity Intelligence’ section directly.</p>
<p>The dashboard is developed using R and the <em>shinydashboard</em> package, and it is my very first shiny app from designing to coding. As I have learnt a great deal during its development, I plan to write some follow-up posts on topics such as how to start your first shiny app, how to choose between shiny and shinydashboard, how to choose the best interactive graph/table packages, how to design your app and some tricks in using reactiveValues and some useful functions such as <em>shinyjs::hide</em>, <em>shinyjs::show</em>, <em>shinyjs::disable</em> and <em>shinyjs::enable</em>.</p>
<p>OK. Let’s cut to the chest and see what the dashboard can do for you (with a deliberate emphasis on the Commodity Intelligence tab because of its powerful analytical ability).</p>
<h2>First impression</h2>
<p>The dashboard has five panels on the left – main dashboard, market intelligence, commodity intelligence, FAQs and StatsNZ releases.</p>
<p>The main dashboard contains “spoon fed” information on trade, which does not require any user input.  On initial load, it only displays high level information in order to save loading time. More detailed trade information will be displayed after clicking the “Show more details” button.</p>
<p><img data-orig-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/first.gif?w=456" data-orig-size="1615,1019" data-medium-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/first.gif?w=456?w=300" data-attachment-id="195" data-image-meta="{" data-image-description="" src="https://nzprimarysectortrade.files.wordpress.com/2018/08/first.gif?w=456" data-permalink="https://nzprimarysectortrade.wordpress.com/2018/10/15/introducing-the-new-zealand-trade-intelligence-dashboard/first/" data-large-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/first.gif?w=456?w=640" alt="first" data-image-title="first" data-comments-opened="1" class="wp-image-195" data-recalc-dims="1"></p>
<h2>Market intelligence</h2>
<p>This tab requires a very simple user input — either one market, or multiple markets or one market group. Additional information on bilateral investment stocks and visitor movements are added. This is the MOST loved and used tab by colleagues from the Ministry of Foreign Affair and Trade.</p>
<p><img data-orig-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/second.gif?w=456" data-orig-size="1615,1019" data-medium-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/second.gif?w=456?w=300" data-attachment-id="196" data-image-meta="{" data-image-description="" src="https://nzprimarysectortrade.files.wordpress.com/2018/08/second.gif?w=456" data-permalink="https://nzprimarysectortrade.wordpress.com/2018/10/15/introducing-the-new-zealand-trade-intelligence-dashboard/second/" data-large-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/second.gif?w=456?w=640" alt="second" data-image-title="second" data-comments-opened="1" class="wp-image-196" data-recalc-dims="1"></p>
<h1>!!!!!!Commodity intelligence!!!!!!</h1>
<p>I love this tab! Why? Because it offers superb analytical ability and flexibility (in my opinion), and it is super easy to use.</p>
<p>After clicking “Commodity Intelligence”, you will see three sub-tabs – Exports, Imports, and Intelligence by HS codes. I will focus on the first and the third one as Imports tab is pretty much identical to its counterpart except that global analysis is NOT available.</p>
<h2>Exports –>  Pre-defined</h2>
<p>After clicking “Exports”, you have two choices either Pre-defined or Self-defined.</p>
<p>Pre-defined means a list of commodities and services defined by Statistics New Zealand (this option does not give user any flexibility to form their own commodities). Those pre-defined ones are principle or key exports earners. You can search or just select as many as you want and then build a report.</p>
<p>The report has two-stages.</p>
<p>First, it will produce high level information for each commodity/service’s trend and growth performance, and then give user an opportunity to select ONE commodity/service for further analysis. <em>Note that users can use the filter boxes above each column in the growth table to narrow down number of commodities. For example, users can filter commodities above certain export values, above certain CAGR5 (5 year compound annual growth rate) or above certain ABS5 (5 year absolute value change).</em></p>
<p>At the second stage, after you select ONE commodity, <span>it will take quite a while (30 seconds, so just be patient) to produce the commodity’s market analysis both domestically (for NZ) and internationally (for the whole world)</span>. The global analysis part accounts for most of the waiting times because it downloads lots of data from <a rel="nofollow" href="https://comtrade.un.org/" target="_blank">UN Comtrade</a>. Also be aware of the query limits of 100 per hour from UN Comtrade , which means the global analysis could be unavailable after reaching the limit. You may need to wait for another hour (<em>There is a note at the very bottom of the page telling the number of query left and when the limit will be reset</em>).</p>
<p><em><strong>My favorite graph is the sankey plot that shows the trade flows from exporters to importers, which also gives user the option to show and hide EU-28 internal trade.</strong></em></p>
<p><img data-orig-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/third.gif?w=456" data-orig-size="1615,1019" data-medium-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/third.gif?w=456?w=300" data-attachment-id="198" data-image-meta="{" data-image-description="" src="https://nzprimarysectortrade.files.wordpress.com/2018/08/third.gif?w=456" data-permalink="https://nzprimarysectortrade.wordpress.com/2018/10/15/introducing-the-new-zealand-trade-intelligence-dashboard/third/" data-large-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/third.gif?w=456?w=640" alt="third" data-image-title="third" data-comments-opened="1" class="wp-image-198" data-recalc-dims="1"></p>
<h2>Exports –>  Self-defined</h2>
<p>It is the coolest option! That is because users will have the flexibility to build their own commodity list based on all 2, 4, and 6 level HS codes.</p>
<p>Users have to follow some STRICT rules to build the HS codes to commodity name grouping/mapping.</p>
<ol>
<li>It has to be a CSV file</li>
<li>The first column has to be HS codes
<ul>
<li>you can mix level 2, 4, 6 HS codes</li>
<li>you can miss the “0” in front of Chapter 1 to 9 as the missing “0” will be auto-filled</li>
</ul>
</li>
<li>The second column has to be the description/name of the commodity</li>
</ol>
<p>After successfully uploading your CSV file, you can build the report and the content of the report is identical to that of Export –> Pre-defined.</p>
<p>Here are two example CSV files. So give a try.</p>
<ol>
<li><a rel="nofollow" href="https://drive.google.com/file/d/1NvoCoFpYfNuel9I6nrs0XDW5WlmGPMcM/view?usp=sharing" target="_blank">Link to Statistics New Zealand Pre-defined commodity CSV file</a></li>
<li><a rel="nofollow" href="https://drive.google.com/file/d/1yfiHotjQd55GNfcLFPGHPjxdMOnwHg18/view?usp=sharing" target="_blank">Link to the CVS file containing all level 6 HS code under Chapter 84, 85, and 86</a></li>
</ol>
<p><img data-orig-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/fourth.gif?w=456" data-orig-size="1615,1019" data-medium-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/fourth.gif?w=456?w=300" data-attachment-id="199" data-image-meta="{" data-image-description="" src="https://nzprimarysectortrade.files.wordpress.com/2018/08/fourth.gif?w=456" data-permalink="https://nzprimarysectortrade.wordpress.com/2018/10/15/introducing-the-new-zealand-trade-intelligence-dashboard/fourth/" data-large-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/fourth.gif?w=456?w=640" alt="fourth" data-image-title="fourth" data-comments-opened="1" class="wp-image-199" data-recalc-dims="1"></p>
<h2>Exports –>  Intelligence by HS Codes</h2>
<p>This is the most convenient tab!</p>
<p>After selecting this tab, you will see a table with three columns – HS level, HS code, and Classification (HS description).</p>
<p>Regular expression rules are applied to each column via the filter boxes above. Users can search a commodity by simply typing the name in the search box or the filter box above Classification. For example, type firework in either search box or box above Classification column.</p>
<p>User can also use the table to generate a CSV file that can be used in Export –> Self-defined. Try this</p>
<ol>
<li>Type 6 in the box above the HS level column</li>
<li>Type ^84|^85|^86 in the box above the HS code column. ^ means starting with. | means or. 84 to 86 are the HS chapters</li>
<li>Click show “All” to display the full table</li>
<li>Click CSV button to download the table as a CSV file</li>
<li>DELET the first column</li>
<li>Now you can use this CSV file as an input for Self-defined analysis</li>
</ol>
<p>To generate an instant report, users simply click on the interested rows in the table. SIMPLE AS!!</p>
<p><img data-orig-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/fifth.gif?w=456" data-orig-size="1615,1019" data-medium-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/fifth.gif?w=456?w=300" data-attachment-id="200" data-image-meta="{" data-image-description="" src="https://nzprimarysectortrade.files.wordpress.com/2018/08/fifth.gif?w=456" data-permalink="https://nzprimarysectortrade.wordpress.com/2018/10/15/introducing-the-new-zealand-trade-intelligence-dashboard/fifth/" data-large-file="https://nzprimarysectortrade.files.wordpress.com/2018/08/fifth.gif?w=456?w=640" alt="fifth" data-image-title="fifth" data-comments-opened="1" class="wp-image-200" data-recalc-dims="1"></p>
<h1>Final thoughts</h1>
<p>The shinydashboard package is awesome. It is very easy to learn for experienced R users. It offers a very simple structure to follow. The dashboard is also MOBILE compatible out of box, which is a big PLUS! The dashboard can be easily adapted to display any countries’ trade intelligence.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://nzprimarysectortrade.wordpress.com/2018/10/15/introducing-the-new-zealand-trade-intelligence-dashboard/"> R related – Project R</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/d6oSComElX8" height="1"></a></div>