Explore your McDonalds Meal with Shiny and D3partitionR


Have you ever wondered what was in your MacDonalds menu? Or in your DoubleCheese Burger (well it’s my favorite one)? A wonderful dataset was released a few months ago, it contains all the nutrition facts from McDonald’s items. You can find the dataset here.

In addition to this, I released a new version of D3partitionR a few weeks ago and was looking for use cases. Hierarchical charts like Sunburst or Treemap are very useful to split and analyze the composition of categories and items. Hence, I decided to make a small Shiny application to analyze the composition and the nutrition value of a MacDonald’s menu.

And here is the app!

Application functionalities

The application has four main tabs:

  1. Menu selection
  2. Calories explorer
  3. Nutrients explorer
  4. Daily Value explorer

Menu Selection

The menu selection is used to … select the items you want to add to your menus. Most of MacDonalds’s items are in there, and there are ordered according to their categories.

Calories explorer

Far more interesting! This part will show you how the calories are spread between the different items, categories, and nutrients (Carbohydrates, Total fat, fibers, and proteins). The zooming makes it easy to see the precise calories composition of each item or categories.

Calories explorer

Daily value and Nutrients explorer

Since calories are not the only element to take into accounts to assess a meal, these two tabs show the value of the different nutrients and their daily value (taken from McDonalds’s website). Various nutrients are available like Saturated fat, Sodium, Vitamin A, … The main point of these tabs was to show a reproducible way to imitate facetting with D3partitionR (which can probably be extended to other widgets).

This slideshow requires JavaScript.

Application Technicalities

The charts in the application mainly rely on D3partitionR and show the main functionalities of D3partitionR:

  • Plotting different types of hierarchical charts with a unified interface
  • Zooming and interactivity with the chart.
  • Shiny bindings as showed in tab 2 where the ggplot is linked to the clicked node.

The application code can be found on Github.



Please enter your comment!
Please enter your name here