is_distributed_normally: Sees if the values of a distribution are normally distributed...

Description Usage Arguments Value Author(s) Examples

Description

Sees if the values of a distribution are normally distributed using a Shapiro-Wilk normality test

Usage

1
is_distributed_normally(values, p_value = 0.05)

Arguments

values

the values to check

p_value

the p value

Value

TRUE when it cannot be rejected that the distribution is normal, FALSE when it can be rejected that the distribution is normal, NA when all values have been identical. The function will call stop if not all values are numeric or the number of values is not between three and five thousand

Author(s)

Richel Bilderbeek

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
   # Set a random number generator seed for reproducible results
   set.seed(42)

   # Create a normal distribution
   nd <- rnorm(n = 1000, mean = 0.0, sd = 1.0)
   # The normal distribution should be normal
   testit::assert(is_distributed_normally(nd))

   # Create a non-normal distribution
   nnd <- runif(n = 1000, min = 0.0, max = 1.0)
   # The non-normal distribution should not be normal
   testit::assert(!is_distributed_normally(nnd))

   # Create a disribution of one value only
   r <- rep(x = 42, times = 100)
   # This one-value distribution should return NA
   testit::assert(is.na(is_distributed_normally(r)))

richelbilderbeek/wiritttea documentation built on May 27, 2019, 8:02 a.m.