How to visualize the distribution of a continuous variable, ezplot - Part 5

Master R

In one of my earlier posts, I showed you how easy it is to make publish-ready histograms and boxplots using the ezplot package. When we’re analyzing a continuous variable, we often also want to know if it’s normally distributed. For example, if it’s normally distributed, we may use linear regression to model it. A good way to check if a continuous variable is normal is to look at its Q-Q plot. Now, there’s an ezplot function that allows you to display the histogram, boxplot, density plot and Q-Q plot all in one figure. Once again, it’s super easy to use and it’s really handy for exploratory analysis. Let me show you how.

Prerequisites

1. Install a set of development tools
• On Mac, install the Xcode command line tools.
• On Linux, install the R development package, usually called r-devel or r-base-dev.
2. Install devtools by running install.packages("devtools") in R.

We’ll plot speed next. We see speed is more or less normally distributed.

I created ezplot out of the frustration that there are too many detailed commands to remember when customizing a ggplot. If ezplot has improved your productivity, please tell your friends about it. In addition, I’m writing a book called ezplot: How to Easily Make ggplot2 Graphics for Data Analysis, and it is 20% complete. Read the sample chapters for FREE and get notified when the book is published.