Learn R Programming

clinpubr (version 1.1.1)

test_normality: Test normality of a numeric variable

Description

Perform multiple normality tests on a numeric variable and determine if it follows normal distribution.

Usage

test_normality(x, alpha = 0.05, all_positive = NULL)

Value

A logical value indicating whether the variable is normal (TRUE) or non-normal (FALSE).

Arguments

x

A numeric vector to test for normality.

alpha

The significance level for normality tests. Default is 0.05.

all_positive

A logical value indicating whether all values are non-negative. If TRUE and standard deviation is less than mean, the variable is considered non-normal (likely right-skewed).

Examples

Run this code
# Test normal data
normal_data <- rnorm(100)
test_normality(normal_data)

# Test non-normal data
skewed_data <- rexp(100)
test_normality(skewed_data)

Run the code above in your browser using DataLab