Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Basics of R

Use the dataset “Food Nutrition”, and answer the following questions:
 Set the working directory for your work
 Import the dataset in the console in the .xls format
 View the top 10 rows of the data
 View the last 20 rows of the data
 Show the summary of the data
 Create a vector “test” using the top 10 values of Protein Variable
 Select the top 5 rows of initial 5 variables in a matrix format
 What is the class of the Sodium_(mg) variable present
 Create a new variable “EPW” by dividing Energ_Kcal with the Water value
 What is the updated dimension of the new dataset
 Create a subset of the dataset, where the Energ_Kcal is less than 500,
what is the dimension of this new dataset
 Plot a Bar Plot between Enrg_Kcal and Water using the new subset
created
 Plot a histogram of Sugar_tot variable using the new subset
 Sort the dataset by Energ_Kcal in descending order and list down the
products that have Zero water quantity
 Create a subset of the data where product description contains “CHEESE”
and list down the summary statistics of the subset
 Using the cut function on water variable divide the whole data into 6 bins,
list down the summary statistics of all the 6 bins

You might also like