Explore your McDonalds Meal with Shiny and D3partitionR

[This article was first published on Enhance Data Science, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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).

Click to view slideshow.

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.

The post Explore your McDonalds Meal with Shiny and D3partitionR appeared first on Enhance Data Science.

To leave a comment for the author, please follow the link and comment on their blog: Enhance Data Science.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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)