Description Usage Arguments Value Author(s) Examples
Sees if the values of a distribution are normally distributed using a Shapiro-Wilk normality test
1 | is_distributed_normally(values, p_value = 0.05)
|
values |
the values to check |
p_value |
the p 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
Richel Bilderbeek
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)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.