Description Usage Arguments Details Value See Also Examples
View source: R/inspect_data_.R
inspect_data_cat_as_dichotom checks if an object contains
valid categorical data that is eligible to be used as dichotomous data. This
can be useful to validate inputs in user-defined functions.
1 2 3 4 5 6 | inspect_data_cat_as_dichotom(
data,
success,
allow_nas = TRUE,
warning_nas = FALSE
)
|
data, success |
Arbitrary objects. |
allow_nas |
Logical value. If |
warning_nas |
Logical value. If |
inspect_data_cat_as_dichotom conducts a series of tests to check
if data contains valid categorical data that is eligible to be used as
dichotomous data. Namely, inspect_data_cat_as_dichotom checks if:
data and success are NULL or empty.
data and success are atomic and have an eligible data type (logical,
integer, double, character).
data and success have NA or NaN values.
success has length 1.
success is observed in data.
inspect_data_cat_as_dichotom does not return any output. There are
three possible outcomes:
The call is silent if:
data contains valid categorical data that is eligible to be used as
dichotomous data and there are no NA or NaN values in data.
data contains valid categorical data that is eligible to be used as
dichotomous data, there are some NA or NaN values in data,
allow_nas is set to TRUE and warning_nas is set to FALSE.
An informative warning message is thrown if:
data contains valid categorical data that is eligible to be used as
dichotomous data and success is not observed in data.
data contains valid categorical data that is eligible to be used as
dichotomous data, there are NA or NaN values in data and both
allow_nas and warning_nas are set to TRUE.
An informative error message is thrown and the execution is stopped if:
data does not contain valid categorical data that is eligible to be
used as dichotomous data.
data contains valid categorical data that is eligible to be used as
dichotomous data, there are some NA or NaN values in data and
allow_nas is set to FALSE.
inspect_data_categorical to validate categorical.
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 26 27 28 29 30 31 32 | # Calls that pass silently:
x1 <- c(1, 0, 0, 1, 0)
x2 <- c(FALSE, FALSE, TRUE)
x3 <- c("yes", "no", "yes")
x4 <- factor(c("yes", "no", "yes"))
x5 <- c(1, 0, 0, 1, 0, NA)
inspect_data_cat_as_dichotom(x1, success = 1)
inspect_data_cat_as_dichotom(x2, success = TRUE)
inspect_data_cat_as_dichotom(x3, success = "yes")
inspect_data_cat_as_dichotom(x4, success = "yes")
inspect_data_cat_as_dichotom(x5, success = 1)
# Calls that throw an informative warning message:
y1 <- c(1, 1, NA, 0, 0)
y2 <- c(0, 0)
success <- 1
try(inspect_data_cat_as_dichotom(y1, success = 1, warning_nas = TRUE))
try(inspect_data_cat_as_dichotom(y2, success = success))
# Calls that throw an informative error message:
try(inspect_data_cat_as_dichotom(y1, 1, allow_nas = FALSE))
try(inspect_data_cat_as_dichotom(NULL, 1))
try(inspect_data_cat_as_dichotom(c(1, 0), NULL))
try(inspect_data_cat_as_dichotom(list(1, 0), 1))
try(inspect_data_cat_as_dichotom(c(1, 0), list(1)))
try(inspect_data_cat_as_dichotom(numeric(0), 0))
try(inspect_data_cat_as_dichotom(1, numeric(0)))
try(inspect_data_cat_as_dichotom(NaN, 1))
try(inspect_data_cat_as_dichotom(NA, 1))
try(inspect_data_cat_as_dichotom(c(1, 0), NA))
try(inspect_data_cat_as_dichotom(c(1, 0), NaN))
try(inspect_data_cat_as_dichotom(c(1, 0), 2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.