When doing descriptive analysis, we often want to see how each variable is distributed. For a continuous variable, this means we want to plot its histogram and check its normality (checking normality of the response variable is necessary when you plan to use linear regression in your inference or predictive analysis). Here’re two small functions that allow you to do that on the fly. They don’t give you dazzling plots for final presentation, however, they do give you informative plots that allow you to see if a variable needs any transformation.
Here’s a demo plot by plot_hist()
:
In this case, horse power is right skewed. As we can see, plot_hist()
overlays a density plot on top of the histogram and draws a red vertical line at the median. I found adding these two things is much more helpful than the default histogram generated by hist()
.
Here’s a demo plot by check_normality()
:
It confirms horse power is not normal. To make it approximately normal, we may do a log transformation since it’s right skewed.