Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We created a mosaic plot of smoking status for each level of exercise in the `survey` dataset in the `MASS` package. library(MASS) surveydata = survey

We created a mosaic plot of smoking status for each level of exercise in the `survey` dataset in the `MASS` package.

library(MASS) surveydata = survey table(surveydata$Exer) table(surveydata$Smoke) mytable = table(surveydata$Exer,surveydata$Smoke) # contingency table (2 arguments to table) mosaicplot(mytable,xlab="Exercise",ylab="Smoking Status",col=2:4) mosaicplot(mytable,xlab="Exercise",ylab="Smoking Status",col=2:5)

The bars and the categories for each bar were not in logical order, but rather alphabetical order. Recreate the mosaic plot putting the levels of smoking status and exercise in a logical order. In order to do this, re-code the values of the variables with numbers and then make the mosaic plot again with the re-coded variables. You can leave the mosaic plot labeled with numbers, but explain in text below your plot what the number codings represent.

First, we will remove row 70 of the dataset since that observation has a missing value for smoking status:

```{r} library(MASS) surveydata = survey[-70,]

Write code using RStudio

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Find the greatest common divisor of the two integers. 32 and 24

Answered: 1 week ago