ANALYSIS ON FOOD DATA SET Certainly! The age range of 15 to 30 is a critical period for growth, development, and overall health. During this time, proper intake of nutrients, including vitamins, fats, proteins, and carbohydrates, is crucial for several reasons: Growth and Development: Adolescents and young adults experience significant physical and mental growth during this period. Nutrients play a vital role in supporting bone development, muscle growth, and brain function. Energy and Metabolism: Young individuals tend to have higher energy requirements due to their active lifestyles and metabolic rates. Carbohydrates and fats are essential sources of energy, while proteins play a role in maintaining muscle mass and supporting various metabolic processes. Immune System Support: Adequate nutrient intake helps strengthen the immune system, making individuals more resilient to infections and illnesses.
data=read.csv("C://Users//tejas//Downloads//fooddata4(2).csv")
summary(data)
## Age carbohydrates vitamins fat
## Min. :15.00 Min. : 1.000 Min. : 1.000 Min. :1.000
## 1st Qu.:20.00 1st Qu.: 3.000 1st Qu.: 4.500 1st Qu.:3.000
## Median :24.00 Median : 6.000 Median : 6.000 Median :4.000
## Mean :23.36 Mean : 5.495 Mean : 5.838 Mean :3.657
## 3rd Qu.:27.00 3rd Qu.: 8.000 3rd Qu.: 7.500 3rd Qu.:4.500
## Max. :30.00 Max. :10.000 Max. :10.000 Max. :8.000
## Proteins
## Min. : 0.000
## 1st Qu.: 5.000
## Median : 6.000
## Mean : 6.111
## 3rd Qu.: 8.000
## Max. :10.000
str(data)
## 'data.frame': 99 obs. of 5 variables:
## $ Age : int 16 17 18 15 17 18 18 17 18 28 ...
## $ carbohydrates: int 8 9 8 7 10 8 9 7 8 9 ...
## $ vitamins : int 4 5 7 5 6 3 5 6 3 5 ...
## $ fat : int 6 4 4 2 2 3 6 6 6 3 ...
## $ Proteins : int 8 5 4 3 6 3 5 2 4 5 ...
#FOOD ANALYSIS
data
## Age carbohydrates vitamins fat Proteins
## 1 16 8 4 6 8
## 2 17 9 5 4 5
## 3 18 8 7 4 4
## 4 15 7 5 2 3
## 5 17 10 6 2 6
## 6 18 8 3 3 3
## 7 18 9 5 6 5
## 8 17 7 6 6 2
## 9 18 8 3 6 4
## 10 28 9 5 3 5
## 11 27 6 3 3 8
## 12 20 7 5 6 9
## 13 18 9 3 4 4
## 14 18 8 6 4 3
## 15 18 9 3 3 5
## 16 17 8 2 4 6
## 17 18 9 4 4 8
## 18 18 8 4 3 4
## 19 15 9 3 4 3
## 20 17 7 6 4 6
## 21 16 9 6 8 4
## 22 30 3 4 1 10
## 23 29 2 5 1 8
## 24 27 3 3 3 7
## 25 26 1 3 4 9
## 26 26 4 8 4 7
## 27 28 2 3 3 8
## 28 20 5 5 5 4
## 29 27 2 6 3 8
## 30 28 3 3 3 7
## 31 28 4 5 4 8
## 32 27 3 4 6 9
## 33 25 5 7 5 9
## 34 27 6 8 3 8
## 35 24 3 7 5 7
## 36 20 4 9 1 9
## 37 17 3 9 1 6
## 38 26 7 6 1 5
## 39 23 8 5 4 5
## 40 23 9 7 4 6
## 41 28 6 4 4 7
## 42 21 8 6 5 8
## 43 19 7 3 5 9
## 44 25 9 5 2 7
## 45 17 10 6 3 4
## 46 18 6 2 3 3
## 47 20 8 3 4 4
## 48 21 6 2 4 5
## 49 21 8 6 4 6
## 50 25 3 7 5 8
## 51 24 2 8 4 6
## 52 19 4 9 4 7
## 53 20 2 8 5 8
## 54 25 1 7 3 5
## 55 25 4 8 2 7
## 56 28 6 9 1 5
## 57 28 3 7 1 8
## 58 29 4 8 3 9
## 59 27 4 9 4 8
## 60 28 6 6 3 9
## 61 26 3 8 6 10
## 62 24 2 5 2 7
## 63 29 6 7 4 8
## 64 28 7 5 2 7
## 65 20 4 7 5 4
## 66 30 6 9 1 5
## 67 24 5 5 6 7
## 68 28 1 7 3 8
## 69 20 3 8 4 5
## 70 18 5 9 4 6
## 71 25 6 6 4 9
## 72 25 3 7 4 6
## 73 26 4 8 3 9
## 74 24 2 5 5 7
## 75 25 5 6 5 8
## 76 24 6 9 5 2
## 77 28 7 5 5 1
## 78 21 8 8 2 5
## 79 24 2 3 2 6
## 80 23 4 5 3 7
## 81 24 9 6 3 6
## 82 25 6 2 4 5
## 83 24 7 1 4 4
## 84 30 5 4 4 8
## 85 28 6 5 2 7
## 86 27 4 6 5 6
## 87 29 8 7 4 2
## 88 21 5 8 4 4
## 89 25 4 5 5 0
## 90 24 3 8 3 3
## 91 26 6 5 3 5
## 92 21 5 8 2 4
## 93 22 7 7 2 2
## 94 28 4 7 2 6
## 95 29 6 9 5 7
## 96 25 3 7 4 7
## 97 26 2 8 4 8
## 98 24 8 9 5 6
## 99 30 1 10 3 10
#TOP FEW ROWS OF THE DATA
head(data)
## Age carbohydrates vitamins fat Proteins
## 1 16 8 4 6 8
## 2 17 9 5 4 5
## 3 18 8 7 4 4
## 4 15 7 5 2 3
## 5 17 10 6 2 6
## 6 18 8 3 3 3
#few rows from down
tail(data)
## Age carbohydrates vitamins fat Proteins
## 94 28 4 7 2 6
## 95 29 6 9 5 7
## 96 25 3 7 4 7
## 97 26 2 8 4 8
## 98 24 8 9 5 6
## 99 30 1 10 3 10
for the plots,we are using ggplot2 library.ggplot2 is a popular R data visualization package that provides an intuitive and flexible framework for creating a wide range of high-quality, customized graphs and plots for data analysis and presentation.
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.2
#barplot
ggplot(data, aes(x =Age, y =vitamins)) +
geom_bar(stat = "identity", fill = "blue") +
labs(title = "age vs vitamins", x = "age", y = "vitamins")
from this plot, we observed the age vs vitamins graph
#histogram
ggplot(data, aes(x =fat)) +
geom_histogram(binwidth = 5, fill = "green", color = "red") +
labs(title = "fats", x = "age", y = "Fats")
we can conclude the same over here also
#scatter plot
ggplot(data, aes(x=Age, y =carbohydrates)) +
geom_point(color = "red") +
labs(title = "carbohydrates", x = "age", y = "carbohydrates")
this plot includes the propotion of the carbohydrates for the particular
age group.
a=table(data$Age)
b=names(a)
a
##
## 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
## 2 2 7 11 2 7 6 1 3 11 11 7 7 13 5 4
share = round(a/sum(a)*100)
a = paste(share,"%",sep="")
the table created above shows the amount of different kind of food taken by the different age groups.
# Create a data frame with the data to be plotted
c <- data.frame(category = b, value = a)
# Create the pie chart using ggplot2
library(ggplot2)
ggplot(c, aes(x = "", y = value, fill = category)) +
geom_bar(stat = "identity", width = 1) +
coord_polar(theta = "y") +
geom_text(aes(label = value), position = position_stack(vjust = 0.5)) +
scale_fill_manual(values = rainbow(length(b))) +
labs(title = "Pie Chart Example")
shows the above analysis in the form of share of pie.
#boxplot
ggplot(data, aes(x =Age, y =Proteins)) +
geom_boxplot(fill = "pink", color = "black") +
labs(title = "food", x = "age", y = "proteins")
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?
this is the box plot among the age and proteins.