In-Class Exercise 4
Shih Chien University
2026-08-03
Using the diamonds dataset, draw a histogram of carat three times, with binwidth set to 0.5, 0.1, and 0.01.
Write one sentence stating which binwidth you would choose and what feature of the data (hint: spikes at “round” carat values) only becomes visible at the smaller binwidths.
Using the mpg dataset, compare the distribution of highway fuel economy (hwy) across drive trains (drv) twice: once with geom_boxplot() and once with geom_violin().
Write one sentence on what the violin plot shows about the shape of the distributions that the boxplot hides (for example, any bimodality in one of the groups).
Using the mpg dataset, plot the mean highway fuel economy for each vehicle class with a point, plus an interval of one standard error around it, using stat_summary():
Write one sentence comparing two classes whose intervals do not overlap and what that suggests about the difference in their average fuel economy.
Complete your answers in the official template from the Problem sets page (author = your student ID only; keep the UUID chunk). Knit to PDF, name it ex4-[StudentID].pdf, and upload it to the course pCloud folder before midnight of the following week.
ggplot2: Elegant Graphics for Data Analysis