title: “MiniProject” author: “Mark Kolotylo” date: “2025-10-17”

###Is McDonalds Really That Unhealthy? A Nutritional Analysis

Getting the data

colnames(menu)

[1] "Category"                      "Item"                         
 [3] "Serving.Size"                  "Calories"                     
 [5] "Calories.from.Fat"             "Total.Fat"                    
 [7] "Total.Fat....Daily.Value."     "Saturated.Fat"                
 [9] "Saturated.Fat....Daily.Value." "Trans.Fat"                    
[11] "Cholesterol"                   "Cholesterol....Daily.Value."  
[13] "Sodium"                        "Sodium....Daily.Value."       
[15] "Carbohydrates"                 "Carbohydrates....Daily.Value."
[17] "Dietary.Fiber"                 "Dietary.Fiber....Daily.Value."
[19] "Sugars"                        "Protein"                      
[21] "Vitamin.A....Daily.Value."     "Vitamin.C....Daily.Value."    
[23] "Calcium....Daily.Value."       "Iron....Daily.Value." 

###What Meals are the most calorically dense?

Clean and convert Calories and Serving.Size to numeric
> menu <- menu %>%
+     mutate(
+         Calories = as.numeric(Calories),
+         Serving.Size = as.numeric(gsub("[^0-9.]", "", Serving.Size))
+     ) %>%
+     mutate(
+         calorie_density = Calories / Serving.Size
+     )
> 
> menu %>%
+     summarise(avg_cal_density = mean(calorie_density, na.rm = TRUE)) %>%
+     arrange(desc(avg_cal_density))

arrange(desc(calorie_density)) %>%
+     select(Item, Calories, Serving.Size, calorie_density) %>%
+     head(10)

###Is The Sodium Content In McDonalds Products Excessively High?

sodium_summary <- menu %>%
+     summarise(
+         avg_sodium = mean(Sodium, na.rm = TRUE),
+         max_sodium = max(Sodium, na.rm = TRUE),
+         min_sodium = min(Sodium, na.rm = TRUE),
+         items_above_limit = sum(Sodium > 2300, na.rm = TRUE),
+         total_items = n(),
+         percent_above_limit = items_above_limit / total_items * 100
+     )
> 
> sodium_summary
  avg_sodium max_sodium min_sodium items_above_limit total_items percent_above_limit
1     495.75       3600          0                 1         260           0.3846154
> 
> sodium_summary_median <- menu %>%
+     summarise(
+         median_sodium = median(Sodium, na.rm = TRUE),
+         max_sodium = max(Sodium, na.rm = TRUE),
+         min_sodium = min(Sodium, na.rm = TRUE),
+         items_above_limit = sum(Sodium > 2300, na.rm = TRUE),
+         total_items = n(),
+         percent_above_limit = items_above_limit / total_items * 100
+     )
> 
> sodium_summary_median
  median_sodium max_sodium min_sodium items_above_limit total_items percent_above_limit
1           190       3600          0                 1         260           0.3846154
> ```

#Healthiest Overall Options?


``` menu <- menu %>%
+     mutate(
+         Calories = as.numeric(Calories),
+         Total.Fat = as.numeric(Total.Fat),
+         Sugars = as.numeric(Sugars)
+     )
> menu <- menu %>%
+     mutate(
+         health_score = Calories + Total.Fat*9 + Sugars*4  # rough estimate of energy from fat & sugar
+     )
> 
> menu %>%
+     arrange(health_score) %>%
+     select(Item, Calories, Total.Fat, Sugars, health_score) %>%
+     head(10)
                      Item Calories Total.Fat Sugars health_score
1        Diet Coke (Small)        0         0      0            0
2       Diet Coke (Medium)        0         0      0            0
3        Diet Coke (Large)        0         0      0            0
4        Diet Coke (Child)        0         0      0            0
5   Diet Dr Pepper (Small)        0         0      0            0
6  Diet Dr Pepper (Medium)        0         0      0            0
7   Diet Dr Pepper (Large)        0         0      0            0
8   Diet Dr Pepper (Child)        0         0      0            0
9      Dasani Water Bottle        0         0      0            0
10        Iced Tea (Small)        0         0      0            0
> menu_food <- menu %>%
+     filter(Calories >= 50)
> menu_food <- menu_food %>%
+     mutate(
+         health_score = Calories + Total.Fat*9 + Sugars*4
+     )
> menu_food %>%
+     arrange(health_score) %>%
+     select(Item, Calories, Total.Fat, Sugars, health_score) %>%
+     head(10)
                                                        Item Calories Total.Fat Sugars
1   Iced Coffee with Sugar Free French Vanilla Syrup (Small)       80       4.5      1
2                                       Nonfat Latte (Small)      100       0.0     13
3                                          Kids French Fries      110       5.0      0
4                           Minute Maid 100% Apple Juice Box       80       0.0     19
5                                        1% Low Fat Milk Jug      100       2.5     12
6  Iced Coffee with Sugar Free French Vanilla Syrup (Medium)      120       7.0      2
7  Nonfat Latte with Sugar Free French Vanilla Syrup (Small)      140       0.0     13
8                                      Nonfat Latte (Medium)      130       0.0     16
9                                          Dr Pepper (Child)      100       0.0     26
10                 Premium Southwest Salad (without Chicken)      140       4.5      6
   health_score
1         124.5
2         152.0
3         155.0
4         156.0
5         170.5
6         191.0
7         192.0
8         194.0
9         204.0
10        204.5
> top_food_healthy <- menu_food %>%
+     arrange(health_score) %>%
+     head(10)```





#PLOT

```ggplot(top_food_healthy, aes(x = reorder(Item, health_score))) +
  geom_bar(aes(y = Calories), stat = "identity", fill = "lightblue") +
  geom_bar(aes(y = Total.Fat*10), stat = "identity", fill = "pink", alpha = 0.6) +
  geom_bar(aes(y = Sugars*10), stat = "identity", fill = "yellow", alpha = 0.6) +
  labs(title = "Top 10 Healthiest Actual Food Items",
       x = "Menu Item", y = "Scaled Value") +
  theme_minimal() +
  coord_flip()

1.From this data we can determine a couple of things, firstly, Calorically McDonalds has plenty of products that are rather high and concentrated, though from a sodium perspective, the food primarily is not extrodinarily high in sodium particularly, though it is important to consider this sodium is on the spectrum of daily intake with the sodium provided being per meal, if you are considering eating 3-4times a day, Mcdonalds would have you lagrely over the sodium intake on average. Due to some sodium items being skewed(Water, tea) being 0, median and average were provided.

2.When it came to the healthiest items, initally 0 calorie items were provided as they were technically the healthiest choices, as water is not anytthing revealing, a filter of a 50 calorie requirement was instilled, to show the healthiest actual fast foods that existed, using a combination of fat, calories, and sugars, though other product parameters such as sodium could be inferred if it were more relevant to the perspective person. Nutritional needs and requisets are heavily specialized, and while Mcdonalds is certainly not HEALTHY, in some components, it is actually less ‘problematic’ as its reputation precedes.