check_normality: Check if observed data can be modeled by the normal...

View source: R/check_normality.R

check_normalityR Documentation

Check if observed data can be modeled by the normal distribution.

Description

The normal distribution is the most commonly used probability distribution. Many real world data such as height can be modeled via the normal distribution. check_normality takes in a data frame and returns a function for making ggplot2 type of CDF plot and the normal probability plot side by side on one canvas of any continuous variable from the data frame. If normal probability plot is linear, the observed data can be modeled by the normal distribution with mean and standard deviation equal to the sample mean and standard deviation of the observed data.

Usage

check_normality(df)

Arguments

df

A data frame.

Value

function(varname, linew = 0.7, xlab_left = varname, title_left, title_right, subtitle_left, subtitle_right, caption_left, caption_right, digits = 2, ...)

  • varname. String, name of a continuous variable. Its empirical CDF will be plotted along side its normal probability plot.

  • linew. Number, width of the line. Default = 0.7.

  • xlab_left. String, x label of the left figure. Default is varname.

  • title_left. String, title of the left figure.

  • title_right. String, title of the right figure.

  • subtitle_left. String, subtitle of the left figure.

  • subtitle_right. String, subtitle of the right figure.

  • caption_left. String, caption of the left figure.

  • caption_right. String, caption of the right figure.

  • digits. Integer, the number of digits after the decimal point for the estimated parameter values of the theoretical distribution. Default = 2.

  • .... Other parameters for making a CDF plot. A common one, for example, is 'add_vline_median = TRUE', which will add a vertical line at the median. Another common one is 'show_label_median = FALSE', which will suppress the display of median value along the median vline. See mk_cdfplot for a full list of parameters.

Examples

inst/examples/ex-check_normality.R

gmlang/ezplot documentation built on Sept. 18, 2022, 6:33 a.m.