Professional Documents
Culture Documents
Assignment Food and Nutrition
Assignment Food and Nutrition
library(readxl)
head(Food_Nutrition,10)
head(Food_Nutrition,20)
summary(Food_Nutrition)
test<-head(Food_Nutrition$`Protein_(g)`,10)
test
Food_Nutrition[1:5,1:5]
class(Food_Nutrition$`Sodium_(mg)`)
#9-Create a new variable "EPW" by dividing Energ_Kcal with the Water; what is the
Food_Nutrition$EPW<-Food_Nutrition$Energ_Kcal/Food_Nutrition$`Water_(g)`
head(Food_Nutrition$EPW)
dim(Food_Nutrition)
#10. Create a subset of the dataset, where the Energ_Kcal is less than 500, what
food_new<-Food_Nutrition[Food_Nutrition$Energ_Kcal<500,]
dim(food_new)
#11-Plot a Bar Plot between Enrg_Kcal and Water using the new subset created
hist(food_new$`Sugar_Tot_(g)`)
x<-Food_Nutrition
y<-x[order(-x$Energ_Kcal),]
head(y$Shrt_Desc,10)
z<-x[order(x$`Water_(g)`),]
head(z$Shrt_Desc,10)
library(dplyr)
m<-filter(x,grepl("CHEESE",x$Shrt_Desc))
head(m$Shrt_Desc)
summary(m)
#15. Using the cut function on water variable divide the whole data into 6 bins, list
l<-Food_Nutrition
View(l)
bin1<-filter(l,l$bins=="A")
View(bin1)
summary(bin1)