Description Usage Arguments Details Value See Also Examples
View source: R/inspect_data_.R
inspect_data_categorical
checks if an object contains data
that is eligible to have been generated by a Multinomial distribution. This
can be useful to validate inputs in user-defined functions.
1 | inspect_data_categorical(data, allow_nas = TRUE, warning_nas = FALSE)
|
data |
An arbitrary object. |
allow_nas |
Logical value. If |
warning_nas |
Logical value. If |
inspect_data_categorical
conducts a series of tests to check if
data
is eligible to have been generated by a Multinomial distribution.
Namely, inspect_data_categorical
checks if:
data
is NULL
or empty.
data
is atomic and have an eligible data type (logical, integer, double,
character).
data
has NA
or NaN
values.
inspect_data_categorical
does not return any output. There are
three possible outcomes:
The call is silent if:
data
is eligible to have been generated by a Multinomial distribution
and there are no NA
or NaN
values in data
.
data
is eligible to have been generated by a Multinomial distribution,
there are some NA
or NaN
values in data
and warning_nas
is set to
FALSE
.
An informative warning message is thrown if: data
is eligible to have
been generated by a Multinomial distribution, there are some NA
or NaN
values in data
and warning_nas
is set to TRUE
.
An informative error message is thrown and the execution is stopped if:
data
is not eligible to have been generated by a Multinomial
distribution.
data
is eligible to have been generated by a Multinomial distribution,
there are some NA
or NaN
values in data
and allow_nas
is set to
TRUE
.
inspect_data_cat_as_dichotom
to validate
categorical data as dichotomous.
inspect_par_multinomial
to validate vectors of
Multinomial proportions.
inspect_data_dichotomous
to validate dichotomous
data.
inspect_par_bernoulli
to validate
Bernoulli/Binomial proportions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # Calls that pass silently:
x1 <- c(1, 0, 0, 1, 2)
x2 <- c(FALSE, FALSE, TRUE, NA)
x3 <- c("yes", "no", "yes", "maybe")
x4 <- factor(c("yes", "no", "yes", "maybe"))
x5 <- c(1, 0, 0, 1, 0, NA, 2)
inspect_data_categorical(x1)
inspect_data_categorical(x2)
inspect_data_categorical(x3)
inspect_data_categorical(x4)
inspect_data_categorical(x5)
inspect_data_categorical(x5)
# Call that throws an informative warning message:
y1 <- c(1, 1, NA, 0, 0, 2)
try(inspect_data_categorical(y1, warning_nas = TRUE))
# Calls that throw an informative error message:
z <- c(1, 1, NA, 0, 0, 2)
try(inspect_data_categorical(z, allow_nas = FALSE))
try(inspect_data_categorical(NULL))
try(inspect_data_categorical(list(1, 0)))
try(inspect_data_categorical(numeric(0)))
try(inspect_data_categorical(NaN))
try(inspect_data_categorical(NA))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.