In this exercise you will learn to visualize the pairwise relationships between a set of quantitative variables. To this end, you will make your own note of 8.5 Mosaic plots from Data Visualization with R.
Mosaic charts can display the relationship between categorical variables using:
The Titanic data set came from https://osf.io/aupb4/.
In the graph below,
The amount of passengers dead are higher than the number that survived.
The largest group that did not survive was class 3 males. There was a total of 441 deaths in class 3.
The largest group that survived was in 1st class females. A total of 134 first class females survived.
One group that has more cases than expected given independence would be within the 3rd class males. More cases of males that did not survive.
One group that has less cases than expected would be the 3rd class males.
Hint: The Arthritis data set is from the vcd package. Add an additional argument gp = shading_max
in the mosaic function. This is because the residuals are too small to have color.
1- More patients did not improve.
2- The largest group was placebos that did not improve.
3- The largest group that did not improve was the treated patients that showed marked improvement.
4- Patients that had marked improvement with treatment had more cases than expected.
5- Marked improvement form placebos had less causes than expected.
Hint: Use message
, echo
and results
in the chunk options. Refer to the RMarkdown Reference Guide.