In this recipe, we will create Quantile-Quantile (Q-Q) plots, which are useful for comparing two probability distributions.
For this recipe, we don't need to load any additional libraries. We just need to type the recipe in the R prompt or run it as a script.
Let's see how the distribution of mpg
in the mtcars
dataset compares with a normal distribution using the qnorm()
function:
qqnorm(mtcars$mpg) qqline(mtcars$mpg)