In this practical, I will analyse the mcdonalds datasets and show reproducible results in a dynamic document are created in R Markdown. R Markdown is great because I can integrate code directly into my document, and easily use italics and bold using formatting tags.

Fast Food Nutrition

Overview

Source: Wikipedia

Source: Wikipedia

The mcdonalds data contains 24 pieces of information for 260 menu items. The data originally comes from https://www.kaggle.com/mcdonalds/nutrition-facts.

Data

Here is a table showing the first 6 columns and 10 rows of the dataset. You can scroll through the dataset and search for specific items you are interested in.

Calories Histogram

Across all items, the mean number of calories is 368.27. The following plot is a histogram showing the distribution of calories across all menu items:

The dataset contains several items with zero calories: Diet Coke (Small), Diet Coke (Medium), Diet Coke (Large), Diet Coke (Child), Diet Dr Pepper (Small), Diet Dr Pepper (Medium), Diet Dr Pepper (Large), Diet Dr Pepper (Child), Dasani Water Bottle, Iced Tea (Small), Iced Tea (Medium), Iced Tea (Large), Iced Tea (Child), Coffee (Small), Coffee (Medium), Coffee (Large) and one item with the maximum amount of calories: Chicken McNuggets (40 piece) of 1880 kCal.

Calories and Sodium Scatterplot

Is there a relationship between the number of calories and sodium in mcdonalds items? To answer this, let’s start by showing a scatterplot:

Calories by Category

Which menu categories have the most calories? To answer this, we’ll start by creating a barplot showing the the mean calories for each menu category

Here is a table showing summary statistics of each category

Summary Statistics of McDonalds Menu item Calories
Category Min Mean Median Max
Chicken & Fish 190 553 480 1880
Smoothies & Shakes 210 531 540 930
Breakfast 150 527 470 1150
Beef & Pork 240 494 500 750
Coffee & Tea 0 284 270 760
Salads 140 270 255 450
Snacks & Sides 15 246 260 510
Desserts 45 222 250 340
Beverages 0 114 100 280

Regression analysis

What predicts Calories best? I conducted a regression analysis using the lm() function here are the main results:

Regression analysis predicting Calories from Total Fat, Sugars and Carbohydrates
term estimate std.error statistic p.value
(Intercept) 13.6 3.29 4.1 0
Total Fat 10.7 0.23 47.7 0
Sugars -0.8 0.15 -5.2 0
Carbohydrates 4.8 0.17 27.5 0