Question: Intro to R programming Question 1: Bob is on a health kick and is keeping track of the macronutrients and calories in what he eats.

Intro to R programming

Intro to R programming Question 1: Bob is on a health kick

Question 1: Bob is on a health kick and is keeping track of the macronutrients and calories in what he eats. Yesterday, he ate Breakfast: 50g of carbs, 8g of fat, and 20g of protein Lunch: 60g of carbs, 30g of fat, and 40g of protein Dinner: 40g of carbs, 30g of fat, 40g of protein Create a matrix that combines the information above. Each meal should be in a different row and the columns should contain the grams of carbs, fat, and protein in the meals. The rownames of the matrix should be breakfast, lunch, and dinner. The colnames should be carbs, fat, and protein. Once you've done that, use R to answer the following questions: 1. How many grams of carbs, fat, and protein did Bob eat yesterday? Assign your answer to a vector named pl. 2. Assume that each gram of carbs yields 4 calories, each gram of protein yields 4 calories, and each gram of fat yields 9 calories. How many calories did Bob eat for breakfast, lunch, and dinner yesterday (assign your answer to a vector named p2)? How many calories did he eat in total (assign your answer to a variable named p3)? Did he stay under his goal of 1800 calories per day (make a comment in the R script by using #)? 3. What percentage of the calories he ate yesterday come from carbs, protein, and fat, respectively (assign your answer to a variable named p4)? He is trying to follow the so-called 40/30/30 diet, where 40 percent of the calories eaten should come from carbs, 30 percent from protein, and 30 percent from fat. Is he close to his goal? If not, suggest how he could get closer (make a comment in the R script by using #)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!