Question

The datafile hotdogs.csv in the Data folder on Avenue gives the measured number of calories and amount of sodium (in mg) for hotdogs from 54 major brands. The data were measured in a laboratory for a Consumer Reports article on the nutritional value of a hotdog. Three types of hotdog were examined, all-beef, poultry or meat (mainly pork and beef but with up to 15% poultry). Use numerical summaries and boxplots to compare these three types of hotdog in terms of calories and sodium content. Write a brief report explaining the results of your analysis. You should also include the R code that you use in your solution. The following code will help you to get the data into an appropriate format hotdogs <- read. csv( hotdogs.csv) calories <- split(hotdogs$Calories, hotdogs$Type) sodium <- split (hotdogs$Sodium, hotdogs$Type) This will create two lists of three vectors each. These vectors can be accessed using the Sname format. For example calories$Beef is the vector of calories in the all-beef hotdogs Can anyone teach me what codes should I use in this question please?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

dat used:

Type Calories Sodium
Beef 186 495
Beef 181 477
Beef 176 425
Beef 149 322
Beef 184 482
Beef 190 587
Beef 158 370
Beef 139 322
Beef 175 479
Beef 148 375
Beef 152 330
Beef 111 300
Beef 141 386
Beef 153 401
Beef 190 645
Beef 157 440
Beef 131 317
Beef 149 319
Beef 135 298
Beef 132 253
Meat 173 458
Meat 191 506
Meat 182 473
Meat 190 545
Meat 172 496
Meat 147 360
Meat 146 387
Meat 139 386
Meat 175 507
Meat 136 393
Meat 179 405
Meat 153 372
Meat 107 144
Meat 195 511
Meat 135 405
Meat 140 428
Meat 138 339
Poultry 129 430
Poultry 132 375
Poultry 102 396
Poultry 106 383
Poultry 94 387
Poultry 102 542
Poultry 87 359
Poultry 99 357
Poultry 107 528
Poultry 113 513
Poultry 135 426
Poultry 142 513
Poultry 86 358
Poultry 143 581
Poultry 152 588
Poultry 146 522
Poultry 144 545

Use

sumamry function in R to get the summary and boxplot function in R to get the result

Rcode is:

hotdogs <- read_excel("C:/Users/M1045151/Downloads/hot dogs.xlsx")
View(hotdogs)
str(hotdogs)
calories <- split(hotdogs$Calories,hotdogs$Type)
print(calories)
sodium <- split(hotdogs$Sodium,hotdogs$Type)
View(calories)
calories$Beef
calories$Meat
calories$Poultry
summary(calories$Beef)
summary(calories$Meat)
summary(calories$Poultry)
summary(sodium$Beef)
summary(sodium$Meat)
summary(sodium$Poultry)

boxplot(hotdogs$Calories~hotdogs$Type,main="Boxplot for hotdogs interms of calories",
xlab="Type", ylab="Calories",col=c("gold","darkgreen","orange"))
boxplot(hotdogs$Sodium~hotdogs$Type,main="Boxplot for hotdogs interms of sodium",
xlab="Type", ylab="Sodium",col=c("gold","green","orange"))

Output:

summary(calories$Beef)
Min. 1st Qu. Median Mean 3rd Qu. Max.
111.0 140.5 152.5 156.8 177.2 190.0
> summary(calories$Meat)
Min. 1st Qu. Median Mean 3rd Qu. Max.
107.0 139.0 153.0 158.7 179.0 195.0
> summary(calories$Poultry)
Min. 1st Qu. Median Mean 3rd Qu. Max.
86.0 102.0 113.0 118.8 142.0 152.0
> summary(sodium$Beef)
Min. 1st Qu. Median Mean 3rd Qu. Max.
253.0 321.2 380.5 401.1 477.5 645.0
> summary(sodium$Meat)
Min. 1st Qu. Median Mean 3rd Qu. Max.
144.0 386.0 405.0 418.5 496.0 545.0
> summary(sodium$Poultry)
Min. 1st Qu. Median Mean 3rd Qu. Max.
357 383 430 459 528 588

Boxplot for hotdogs interms of calories Beef Meat Poultry TypeBoxplot for hotdogs interms of sodium Beef Meat Poultry TypeIntrepretation:

Calories is highest for the type meat as median=153

sodium is highest for the type poultry as median=459.

From boxplot there are differences in mean calories for the three different types of hotdogs

From boxplot we also observe there is a re differences in mean sodium for the three different types of hotdogs.

Boxplot for hotdogs interms of calories Poultry Beef Meat Type

Boxplot for hotdogs interms of sodium Poultry Beef Meat Type

Add a comment
Know the answer?
Add Answer to:
Can anyone teach me what codes should I use in this question please? The datafile hotdogs.csv...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but...

    If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but minor discrepancies may require you to adjust. If you are attempting this assignment using another version of Visual Studio, you can expect differences in the look, feel, and/or step-by-step instructions below and you’ll have to determine the equivalent actions or operations for your version on your own. INTRODUCTION: In this assignment, you will develop some of the logic for, and then work with, the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT