check_type: Quantitatively check on variables

View source: R/misc.R

check_typeR Documentation

Quantitatively check on variables


This internal function is to be used in the prep function to ensure that the type of the variables matches the expectation. Throws an error if check fails.


check_type(dat, quant = TRUE, types = NULL, call = caller_env())



A data frame or tibble of the training data.


A logical indicating whether the data is expected to be numeric (TRUE) or a factor/character (FALSE). Is ignored if types is specified.


Character vector of allowed types. Following the same types as has_role(). See details for more.


Using types is a more fine-tuned way to use this. function compared to using quant. types should specify all allowed types as designated by .get_data_types. Suppose you want to allow doubles, integers, characters, factors and ordered factors, then you should specify types = c("double", "integer", "string", "factor", "ordered") to get a clear error message.

recipes documentation built on March 7, 2023, 6:14 p.m.