Part 1: Getting insghts of the data

Importing data into RStudio

library(here)
## here() starts at C:/Users/jalen/OneDrive/Documents
starb_data <- read.csv(here("Data", "starbucks.csv"))

The names of the varibales on the data sheet

names(starb_data)
## [1] "item"     "calories" "fat"      "carb"     "fiber"    "protein"  "type"

In total, there are 77 entries and 7 categories in the data

Part 2: Descriptive Data Analysis

Part 2.1: Graphical Data Analysis

Import the following the libraries

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)

Making a histogram with hist() function

hist(starb_data$protein,
     xlab = "Grams of Protein",
     ylab = "Number of food items",
     main = "Amount of protein in Starbucks food",
     breaks = 8,
     col = "green",
     labels = TRUE,
     ylim = c(0,30))

Median for protein data is 7

Part 2.2: Data aggregation

Frequency distrubtion

group_by(starb_data, type) %>% # Group the starb_data by variable type 
summarise(counts = n()) # Calculate the number of food items in each category 
## # A tibble: 7 × 2
##   type          counts
##   <chr>          <int>
## 1 bakery            41
## 2 bistro box         8
## 3 hot breakfast      8
## 4 parfait            3
## 5 petite             9
## 6 salad              1
## 7 sandwich           7

Most frequent food is “Bakery”

Least frequent food is “Salad”

Separating food items with more than 15 grams of Protein

subset(starb_data, protein > 15) %>% 
group_by(type)%>%
summarise(average_protein = mean(protein))
## # A tibble: 3 × 2
##   type          average_protein
##   <chr>                   <dbl>
## 1 bistro box               20.8
## 2 hot breakfast            18.3
## 3 sandwich                 28.4

Recommended food to build muscles are sandwiches, hot breakfast, and the bistro box