get_data_classes: Extract data classes from a data frame or matrix

Description Usage Arguments Value Examples

View source: R/classes.R

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

1

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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)

DavisVaughan/hardhat documentation built on Oct. 5, 2021, 9:53 a.m.