Plotting opportunity cost
Again, interest is in whether the treatment and control groups were equally likely to buy a DVD after reading the experimental statements. Here, you'll create a barplot to visualize the difference in proportions between the treatment and control groups.
This exercise is part of the course
Foundations of Inference in R
Exercise instructions
- Using the
opportunity
dataset, plotgroup
fill
ed bydecision
. - Call
geom_bar()
to add a bar plot layer, setting the position argument to"fill"
to compare relative frequencies. Note that fill should be defined by thedecision
for each group.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot group, filled by decision
ggplot(opportunity, aes(x = ___, fill = ___)) +
# Add a bar layer, with position "fill"
___