Contributed by Adam Cone.He is currently in the NYC Data Science Academy 12 week full time Data Science Bootcamp program taking place between April 11th to July 1st, 2016. This post is based on his second class project - R Shiny (due on the 4th week of the program). The video of his presentation is here:
May 9, 2016
Open Produce is small grocery store on the south side of Chicago. The owners wrote their own Point-of-Sale (POS) system to collect data relating to deveries, inventory, sales, and other aspects of the business. Open Produce made some of their total revenue data available in an interactive format on their website:
The overall revenue trend seems pretty consistently positive since Open Produce began taking data. Kudos to Open Produce! Mazel tov! For my Shiny project, I wanted also look at overall revenue. Specifically, I wanted to provide both Open Produce staff and customers a free an easy way to visualize the data themselves to gain insights. To this end, I developed the following Shiny app, hosted by Shinyapps.io here:
To generate this app, I first prepared the data with an R file, then wrote the app itself using three more R files: ui.R, server.R, and helpers.R. The data wrangling code is:
After this data wrangling, my data looked like this:
Now, for the Shiny code. Here's the ui.R code:
Here's the server.R code:
And here's the helpers.R code:
Playing around with the app myself led me to two insights that I didn't have beforehand, although I had spent a lot of time with the data. First, I noticed that the total Open Produce revenue, in approximately 4 month bins, essentially quadrupled between the first bin and the final bin for the 6.5 years of data I had ( about $100,000 to $400,000 total revenue over each four-month period). In addition, the growth was roughly constant over the intervening ~6 years.
So, I was interested in sub-categories that may not obey this trend. One was revenue collected from items purchased with Payment Type Credit/Debit only:
It seems that while overall revenue increased smoothly by a factor of about 4, Credit/Debit purchases increased smoothly from about $40,000 to $250,000, or a factor of 6.25 over the same period. It appears to me that Credit/Debit purchases were disproportionately responsible for the overall revenue increase.
In addition, narrowing the Product Unit Price Range ($) to $10-$15 was even more extreme:
The growth in products with unit prices from $10-15 was enormous. There was essentially no revenue from these products until about July 2010, when they started steadily increasing. After that, the growth seemed to spike in early 2015. While this data was available before I had looked at the Shiny app, I didn't make this connection until I could visualize the data. Also, using Shiny, I was able to pinpoint that the majority of revenue generated from $10-15 items was sold in the middle Time of Day: 2:00pm-8:00pm.
If I were to develop this app further, besides prettying it up a bit, I would want to include more item categories, such as dairy/frozen/drinks, etc. Also, it would be interesting to have data about where the items were physically in the store when they were purchased.