GithubHelp home page GithubHelp logo

djsir-data / djprtradedash Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 395.18 MB

DJPR Trade Dashboard

Home Page: https://global.vic.gov.au/our-programs-and-services/our-programs/victorian-trade-exports

License: Other

R 86.76% CSS 13.14% JavaScript 0.10%
trade imports exports shiny shiny-apps victoria r rstats

djprtradedash's Introduction

djprtradedash

R-CMD-check Codecov test coverage

The DJPR Trade Dashboard provides a convenient way for users to browse publicly-accessible data about Victorian exports and imports.

Installing the package

Install from GitHub with:

if (!requireNamespace("remotes")) {
  install.packages("remotes")
}

remotes::install_github("djpr-data/djprtradedash", dependencies = TRUE)
library(djprtradedash)

Data functions

djprtradedash contains functions to download and tidy trade data from publicly-available sources such as the ABS.

Import ABS balance of payments data by State/Territory with read_bop():

read_bop()
#> # A tibble: 5,136 x 8
#>    exports_imports indicator     goods_services state                        date       value series_id  unit      
#>    <chr>           <chr>         <chr>          <chr>                        <date>     <dbl> <chr>      <chr>     
#>  1 Exports         Current Price Goods          New South Wales              2011-09-01 11349 A85092741C $ Millions
#>  2 Exports         Current Price Goods          Victoria                     2011-09-01  5756 A85092752K $ Millions
#>  3 Exports         Current Price Goods          Queensland                   2011-09-01 14302 A85092700J $ Millions
#>  4 Exports         Current Price Goods          South Australia              2011-09-01  2959 A85092678X $ Millions
#>  5 Exports         Current Price Goods          Western Australia            2011-09-01 31872 A85092753L $ Millions
#>  6 Exports         Current Price Goods          Australian Capital Territory 2011-09-01     3 A85092743J $ Millions
#>  7 Exports         Current Price Services       New South Wales              2011-09-01  5832 A85092746R $ Millions
#>  8 Exports         Current Price Services       Victoria                     2011-09-01  3280 A85092714W $ Millions
#>  9 Exports         Current Price Services       Queensland                   2011-09-01  2440 A85092681L $ Millions
#> 10 Exports         Current Price Services       South Australia              2011-09-01   574 A85092701K $ Millions
#> # ... with 5,126 more rows

Import ABS merchandise exports data with read_merch():

read_merch(min_date = as.Date("2021-01-01"),
                          max_date = as.Date("2021-02-01"))
#> Downloading NSW export merchandise trade data from 2021-01 to 2021-02
#> Downloading VIC export merchandise trade data from 2021-01 to 2021-02
#> Downloading QLD export merchandise trade data from 2021-01 to 2021-02
#> Downloading SA export merchandise trade data from 2021-01 to 2021-02
#> Downloading WA export merchandise trade data from 2021-01 to 2021-02
#> Downloading TAS export merchandise trade data from 2021-01 to 2021-02
#> Downloading NT export merchandise trade data from 2021-01 to 2021-02
#> Downloading ACT export merchandise trade data from 2021-01 to 2021-02
#> Downloading NA export merchandise trade data from 2021-01 to 2021-02
#> Downloading REEXP export merchandise trade data from 2021-01 to 2021-02
#> # A tibble: 71,504 x 8
#>    date       country_dest             sitc_rev3                          sitc_rev3_code origin        unit  value export_import
#>    <date>     <chr>                    <chr>                              <chr>          <chr>         <chr> <dbl> <chr>        
#>  1 2021-02-01 Bhutan                   Commodities and transactions not ~ 9              Australian C~ 000s      3 export       
#>  2 2021-01-01 Hong Kong (SAR of China) Commodities and transactions not ~ 9              Australian C~ 000s    558 export       
#>  3 2021-01-01 Total                    Commodities and transactions not ~ 9              Australian C~ 000s    558 export       
#>  4 2021-02-01 Total                    Commodities and transactions not ~ 9              Australian C~ 000s    545 export       
#>  5 2021-02-01 United States of America Commodities and transactions not ~ 9              Australian C~ 000s    542 export       
#>  6 2021-01-01 Hong Kong (SAR of China) Gold coin whether or not legal te~ 95             Australian C~ 000s    558 export       
#>  7 2021-01-01 Hong Kong (SAR of China) Gold coin whether or not legal te~ 951            Australian C~ 000s    558 export       
#>  8 2021-01-01 Total                    Gold coin whether or not legal te~ 95             Australian C~ 000s    558 export       
#>  9 2021-01-01 Total                    Gold coin whether or not legal te~ 951            Australian C~ 000s    558 export       
#> 10 2021-02-01 Spain                    Measuring, checking, analysing an~ 874            Australian C~ 000s    534 export       
#> # ... with 71,494 more rows

Import ABS International Trade Supplementary Information with read_supp():

read_supp("cy", 3)
#> # A tibble: 9,702 x 5
#>    item                                                      year  value subset abs_series                                      
#>    <chr>                                                     <chr> <dbl> <chr>  <chr>                                           
#>  1 Manufacturing services on physical inputs owned by others 1999     NA NSW    Table 3.1 International Trade in Services, Cred~
#>  2 Maintenance and repair services n.i.e                     1999     29 NSW    Table 3.1 International Trade in Services, Cred~
#>  3 Transport                                                 1999   2724 NSW    Table 3.1 International Trade in Services, Cred~
#>  4 Passenger (b)                                             1999   1563 NSW    Table 3.1 International Trade in Services, Cred~
#>  5 Freight                                                   1999    235 NSW    Table 3.1 International Trade in Services, Cred~
#>  6 Other                                                     1999    728 NSW    Table 3.1 International Trade in Services, Cred~
#>  7 Postal and courier services (c)                           1999    198 NSW    Table 3.1 International Trade in Services, Cred~
#>  8 Travel                                                    1999   5132 NSW    Table 3.1 International Trade in Services, Cred~
#>  9 Business                                                  1999    623 NSW    Table 3.1 International Trade in Services, Cred~
#> 10 Personal                                                  1999   4509 NSW    Table 3.1 International Trade in Services, Cred~
#> # ... with 9,692 more rows

Data objects

The file data-raw/create_dash_data.R uses the data functions (see above) to download and tidy data. That data is then stored as internal data objects in this package.

  • merch is merchandise exports data from read_merch()

  • bop is balance of payments data from read_bop()

  • supp_cy is supplementary calendar year trade information from read_supp("cy")

  • supp_fy is supplementary financial year trade information from read_supp("fy")

djprtradedash's People

Stargazers

 avatar  avatar  avatar

djprtradedash's Issues

Check package dependencies

There's a lengthy list of dependencies but I think a bunch like readsdmx aren't being used. Probably need to check through them all and cull all unused.

Launchpad: drawing distinction between percentage share and percentage change in charts

It has been pointed out that it can be confusing to interpret tables at the bottom of the launchpad as figures in brackets are all in percentages, however the first column is a percentage share, whereas in the other columns they are percentage changes. Some changes are proposed below:

  • Add a vertical line to visually separate the first column (percentage share) from the other columns with changes
  • Use conditional formatting, such as the use of colours or arrows to denote where the percentage changes are positive or negative. As this would not apply to the first column this is another distinction.

BOP: Fix goods line charts

There is currently an issue where line charts are not showing the correct data for the period in the slider and the chart x axis boundaries. There is currently a lag of 1 year, so if the slider is selecting Dec 2019 to Dec 2021, then the data will actually show Dec 2020 to Dec 2021. A proposed source for this issue lies in the djpr_ts_linechart() function of the djprshiny package as the charts were working as intended prior to the change to the function.

General: New page for merchandise category profiles

In the longer-run, it has been suggested that having a page that focuses on individual goods would be useful. In light of the fact that we have shortened SITC good names now, it might be a good way to combine both of these issues into one. A page where users can see a list of all the products and their full SITC code and name and can then click further to find out more about particular goods.

Bop: Fix the growth bar charts label

Change the growth bar charts label for goods and services to one decimal place to be consistent with other charts. At present, it is in two decimal places.

Launchpad: combine launchpad tables to conserve space

At the moment all of the tables are separate but have similar/identical headings, it may look more appealing for these tables to be combined with headings delineating sections as is the case in the labour dashboard.

Add database to dev or deploy script

Dev currently relies on the database but it's not currently in the repo due to size. If we want to set up automatic deploy on pull to main, then we will either need to add the database via LFS or add database construction to the github action deploy script.

Expand and fill NA's in database

currently datasets are expanded and filled within R. Need to determine if this is possible in DB and if there is any processing implication

Launchpad: Add BOP chart to the bottom of the page

It has been agreed that one of the better candidates for where a table with BOP may be included is at the bottom of the Launchpad. It is suggested that this table be formatted to look like the others for consistency.

General: Fix `read_merch()` function to update data as needed

With the latest release of ABS.Stat merchandise data, the data file is too large to be unzipped in R and is causing errors when using read_merch() in order for the dashboard to automatically populate with new data, this function must be fixed or amended.

Launchpad: Change Top Export Chart Labels

While the overlapping issue has been somewhat resolved, it would be clearer to have shorter names. The proposed label change is from "SITC name" to "SITC CODE: SITC name (limited characters)".

General: Load speed improvements

At present the trade dashboard is taking close to 2 minutes to load on opening, in order to avoid users potentially thinking the dashboard is not working, we should address the speed before wider release.

TOT: Total breaks app in merch explorer

How to replicate:

  1. Select all SITC levels
  2. Add "TOT: Total" to goods
  3. Watch it all come down

Issue around bind_rows and incorrect classes for some reason. Possible fixes are explicit reclass or simply removing the total row

Merchandise Exports Chart facet vertically on narrow screen

The current chart facets along the row, this needs to change to column, depending on the with of the screen. This will be particularly important on a mobile device. Shiny is able to check screen size and dimensions as well as the type of device in use.

Use these elements to modify the chart when needed

BOP: Fix cumulative exports chart labels

At present the chart labels for the cumulative exports chart in the Balance of Payments page is calculating the wrong figures. A proposed source for this issue is the scales::dollar() function, as the numeric data that in the dataset that is generating the chart and title has correct figures.

General: Line chart labels not showing units

There is currently an issue where the end labels for line charts are not showing the units of the values. E.g. "1.9" instead of "1.9%". A proposed source for this issue lies in the djpr_ts_linechart() function of the djprshiny package as the charts were working as intended prior to the change to the function.

Update all UI fonts to VIC font

All fonts on a government page need to be VIC font. For now the easiest way to do this will be via CSS.

As all the charts are svg from ggiraph they are ope to styling. For example chart titles are class shiny-text-output shiny-bound-output. Use these classes to set the font face. In the CSS file it will be something like:

shiny-text-output, shiny-bound-output {
font-family:'vic-regular' sans-serif;
}

Launchpad: Clarify goods charts & data adjustments

Caroline Hartnett from Global Vic has requested a little clarification on launchpad charts. Specifically, that the export product charts clearly label that they are goods only. Also, it would be good to experiment and see if there are clearer ways to present information on data adjustments (e.g. seasonally adjusted, rolling averages and chain volume measures). If we find the caption is the easiest way, I am happy to stick with that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.