Code Studio: Boxplots and Outliers
Introduction to Boxplots explains what a box shows. Draw one per group, then compute what a box is made of.
The InsectSprays dataset counts insects after six sprays, A to F. The program reads one spray letter.
- With ggplot2, draw a boxplot of
countfor everyspray, andprint()it. - For the spray that was read, print its median and its interquartile range (
IQR()), and how many of its countsboxplot.stats()marks as outliers:
For spray A:
Median: 14 IQR: 6.25 Outliers: 0
Hint: boxplot.stats(x)$out holds the outliers.
Which sprays are clearly more effective? Can you see it in the boxes before you compute anything?
Run draws your plot under the output. Check and Submit test the numbers your program prints.
Introduction to Boxplots explains what a box shows. Draw one per group, then compute what a box is made of.
The InsectSprays dataset counts insects after six sprays, A to F. The program reads one spray letter.
- With ggplot2, draw a boxplot of
countfor everyspray, andprint()it. - For the spray that was read, print its median and its interquartile range (
IQR()), and how many of its countsboxplot.stats()marks as outliers:
For spray A:
Median: 14 IQR: 6.25 Outliers: 0
Hint: boxplot.stats(x)$out holds the outliers.
Which sprays are clearly more effective? Can you see it in the boxes before you compute anything?
Run draws your plot under the output. Check and Submit test the numbers your program prints.