This question showed how to make a qqplot with a qqline in ggplot2, but the answer only seems to work when plotting the entire dataset in a single graph.
I want a way to quickly compare these plots for subsets of my data. That is, I want to make qqplots with qqlines on a graph with facets. So in the following example, there would be lines for all 9 plots, each with their own intercept and slope.
df1 = data.frame(x = rnorm(1000, 10),
y = sample(LETTERS[1:3], 100, replace = TRUE),
z = sample(letters[1:3], 100, replace = TRUE))
ggplot(df1, aes(sample = x)) +
stat_qq() +
facet_grid(y ~ z)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…