Retail Data Visualization with R and Shiny

February 3, 2019

(This article was first published on R – NYC Data Science Academy Blog, and kindly contributed to R-bloggers)


Because of my marketing background, finding information hiding wihtin a marketing dataset is always an interesting topic to me. It makes me feel a sense of accomplishment when I cleaned up a very messy large dataset, and finally discover some insights from it. Therefore, I’ve decided to practice my skills of data cleaning and visualization by using this Brazilian online retail sales dataset for my first shiny project during the bootcamp. My objective of this project is to gain experience of dealing with large sales dataset, so I could feel more confident when facing any other multi-dimensional datasets like this one in the future. Link of my project. If you want to view my coding, this is my github repo.

The Dataset

The dataset I used is from, and it is provided by the largest Brazilian online department store called olist. From the database sigma below you will see, the dataset contains 8 separated datasets in total, stored multi-dimensional data about over 100k orders’ information of olist from end of 2016 to 2018. It is a great database for us to understand the Brazilian E-commerce from multiple perspectives.

The Project

First, is the data cleaning process. Because the raw data has 8 datasets in total, and with a lot of duplicates and useless information, I spent some time joining them to collect the variables I need, and removed some unnecessary data. Dplyr became a very handy tool during this process. After the cleaning, I generate a final_order table with 19 variables, and only include the data I need for my data visualization.

My shiny interface have three sections in total, the first one is the geographic section. With this one user could view the data from a State perspective. They can plot any variables like Total Sales, Average Shipping Cost or Average Delivery Days on the map, and comparing them between states. The right corner section allows user to discover correlations between each variables, and see the actually numbers of the variable they picked

Trends section is focusing on sales trends over time, between each categories. Users could pick the date range and categories that they want to compare, the line chart in the major section will output the result clearly. The yellow sections give users the access to the daily data numbers.

The last section allow users to view the data from a categories stand point. You can easily pick any categories you want to compare, and see the bar chart to compare total sales, average unit sales and average review score between different categories.

To leave a comment for the author, please follow the link and comment on their blog: R – NYC Data Science Academy Blog. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)