Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

get_data_classes

Extract data classes from a data frame or matrix


Description

When predicting from a model, it is often important for the new_data to have the same classes as the original data used to fit the model. get_data_classes() extracts the classes from the original training data.

Usage

get_data_classes(data)

Arguments

data

A data frame or matrix.

Value

A named list. The names are the column names of data and the values are character vectors containing the class of that column.

Examples

get_data_classes(iris)

get_data_classes(as.matrix(mtcars))

# Unlike .MFclass(), the full class
# vector is returned
data <- data.frame(col = ordered(c("a", "b")))

.MFclass(data$col)

get_data_classes(data)

hardhat

Construct Modeling Packages

v0.1.5
MIT + file LICENSE
Authors
Davis Vaughan [aut, cre], Max Kuhn [aut], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.