library(readxl)
## Warning: package 'readxl' was built under R version 3.5.3
DB_DataVizProject_Food <- read_excel("C:/Users/Priya/Downloads/DB-DataVizProject-All.xlsx", 
    sheet = "Food")
DB_DataVizProject_WK <- read_excel("C:/Users/Priya/Downloads/DB-DataVizProject-All.xlsx", 
    sheet = "Workout")
DB_DataVizProject_WKdate <- read_excel("C:/Users/Priya/Downloads/DB-DataVizProject-All.xlsx", 
    sheet = "Sheet1")
Priya <- DB_DataVizProject_Food[1:154,]
Priya_wk <- DB_DataVizProject_WK[1:21,]
PriyaWk1 <- Priya[1:56,]
PriyaWk2 <- Priya[57:101,]
PriyaWk3 <- Priya[102:154,]
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.3
Priya$Date <- Priya$`Date (mm/dd/yyyy)`
PriyaWk1$Date <- PriyaWk1$`Date (mm/dd/yyyy)`
PriyaWk2$Date <- PriyaWk2$`Date (mm/dd/yyyy)`
PriyaWk3$Date <- PriyaWk3$`Date (mm/dd/yyyy)`
Priya_wk$Date <- Priya_wk$`Date (mm/dd/yyyy)`
Priya_wkdate <- DB_DataVizProject_WKdate[1:21,]
library(tidyr)
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.5.2
## 
## 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(ggmap)
## Warning: package 'ggmap' was built under R version 3.5.3
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
Priya$Carbs <- Priya$`Carbs(g)`
Priya$Fat <- Priya$`Fat(g)`
Priya$Proteins <- Priya$`Proteins(g)`
Priya_n <- Priya[,c(7,10)]
Priya_s <- Priya[,c(8,10)]

Priya$`Day of the Week` <- as.character(Priya$`Day of the Week`)

Priya$`Day of the Week` <- factor(Priya$`Day of the Week`, levels=unique(Priya$`Day of the Week`))

Priya$`Day of the Week` <- factor(Priya$`Day of the Week`, levels=c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))

# QUESTION 01 

# What distribution of calorific value during every week based on Different Food Type.

ggplot(PriyaWk1, aes(x = Date, y = Calories)) + 
  geom_col(aes(color = `Food Type`, fill = `Food Type`))

#As shown in the Week 01 Graph for Priya the Average Calorific Value is 1980. Saturday and Wednesday show the highest Calorific Value during Week 01 and Grain, Snacks are the top two Food Type categories and Lean Meats and Poultry being the least contributor. 

ggplot(PriyaWk2, aes(x = Date, y = Calories)) + 
  geom_col(aes(color = `Food Type`, fill = `Food Type`))

#As shown in the Week 02 Graph for Priya the Average Calorific Value is 2176. Friday and Thursday show the highest Calorific Value during Week 02 and Grain, Fruits are the top two Food Type categories and Dairy being the least contributor. 

ggplot(PriyaWk3, aes(x = Date, y = Calories)) + 
  geom_col(aes(color = `Food Type`, fill = `Food Type`))

#As shown in the Week 03 Graph for Priya the Average Calorific Value is 2208. Friday and Wednesday show the highest Calorific Value during Week 03 and Grain, Vegan are the top two Food Type categories and Snacks being the least contributor. 

#Conclusion- Priya is 27 Years old Female who weighs 60 Kgs is 161 cms tall. He consumed on an average over the three-week period 2121.33 calories. As per the Harris-Benedict Equation for Basal Energy Expenditure (BEE), which is Men: BEE = 66.5 + 13.8(W) + 5.0(H) - 6.8(A) and Women: BEE = 655.1 + 9.6(W) + 1.9(H) - 4.7(A), Priya’s BEE should be [66.5+ 13.8(60) + 5.0(161) - 6.8(30)] = 1495.5. Also, BEE may need to be multiplied by a factor of 1.2-1.5 to account for extra calories needed during exercise. A factor of 1.2 represents an average amount of activity, where 1.5 would be a very high amount of activity. Since Priya does average amount of activity hence her BEE should be multiplied by a factor of 1.2. Therefore, his new BEE is 1495.5*1.2 which is 1794.6. Hence, Priya is consuming more Calories as compared to the BEE number

df_priya <- data.frame(value = c(5681.50, 1676.10, 1126.10),
                 Group = c("Carbs", "Proteins", "Fats")) %>%
   mutate(Group = factor(Group, levels = c("Fats", "Proteins", "Carbs")),
          cumulative = cumsum(value),
          midpoint = cumulative - value / 2,
          label = paste0(Group, " ", round(value / sum(value) * 100, 1), "%"))

# QUESTION 02 

# What is the distribution of the 3 major Nutrients in grams. 

ggplot(df_priya, aes(x = 1, weight = value, fill = Group)) +
   geom_bar(width = 1, position = "stack") +
   coord_polar(theta = "y") +
   geom_text(aes(x = 1.3, y = midpoint, label = label)) +
   theme_nothing()               

## QUESTION 03 

## What is distribution of eating habits based on Different Food Types.

ggplot(Priya_n, aes(x="", y=Calories, fill=`Food Type`))+
geom_bar(width = 1, stat = "identity") + 
  coord_polar("y", start=0)

#From the pie-chart we can see that Priya’s major food intake is from Grain and Vegan food type while Snacks and Lean Meats and Poultry are the least contributors. 

## QUESTION 04 

## What is distribution of eating habits based on Different Food Sources.

ggplot(Priya_s, aes(x="", y=Calories, fill=`Food Source`))+
geom_bar(width = 1, stat = "identity") + 
  coord_polar("y", start=0)

#From the pie-chart we can see that Priya’s major food intake is from Home Cooked and Natural/Raw food source while Food Truck/Street Food and pre-Cooked are the least contributors. 

## QUESTION 05 

## What is distribution of eating habits based on Different Food Sources over different days of the week. 

ggplot(Priya, aes(x = `Day of the Week`, y = Calories)) + 
  geom_col(aes(color = `Food Source`, fill = `Food Source`))

#Home Cooked- During Friday and Wednesday Priya eats more Home Cooked food than the rest of the days of the week. 

#Natural/Raw - Consistent Distribution during the week. 

#Restaurant- Major contributor on Friday and Wednesdays 

#Pre-Cooked- It is only showing Wednesday, Thursday and Friday. 

#Food Truck/Street Food- It only showing Tuesday and Sunday. 

#Packaged Snacks- Consistent Distribution during the week. 

# QUESTION 06 

# Distribution of Calories Consumed vs Calories burned through Physical Exercises over different days of the week.

ggplot() + 
  geom_col(data = Priya_wkdate, aes(x = Date, y = Calories), color = "cyan", fill = "white") +
  geom_line(data = Priya_wk, aes(x = `Date (mm/dd/yyyy)`, y = `Calories Burnt`), color = "red") +
  xlab('Date') +
  ylab('Calorie difference')