The .get_data_types()
generic is used internally to supply types to
columns used in recipes. These functions underlie the work that the user sees
in selections.
Usage
.get_data_types(x)
# S3 method for default
.get_data_types(x)
# S3 method for character
.get_data_types(x)
# S3 method for ordered
.get_data_types(x)
# S3 method for factor
.get_data_types(x)
# S3 method for integer
.get_data_types(x)
# S3 method for numeric
.get_data_types(x)
# S3 method for double
.get_data_types(x)
# S3 method for Surv
.get_data_types(x)
# S3 method for logical
.get_data_types(x)
# S3 method for Date
.get_data_types(x)
# S3 method for POSIXct
.get_data_types(x)
# S3 method for list
.get_data_types(x)
# S3 method for textrecipes_tokenlist
.get_data_types(x)
# S3 method for hardhat_case_weights
.get_data_types(x)
Details
This function acts as an extended recipes-specific version of class()
. By
ignoring differences in similar types ("double" and "numeric") and allowing
each element to have multiple types ("factor" returns "factor", "unordered",
and "nominal", and "character" returns "string", "unordered", and
"nominal") we are able to create more natural selectors such as
all_nominal()
, all_string()
and all_integer()
.
The following list shows the data types for different classes, as defined
by recipes. If an object has a class not supported by .get_data_types()
,
it will get data type "other".
character: string, unordered, and nominal
ordered: ordered, and nominal
factor: factor, unordered, and nominal
integer: integer, and numeric
numeric: double, and numeric
double: double, and numeric
Surv: surv
logical: logical
Date: date
POSIXct: datetime
list: list
textrecipes_tokenlist: tokenlist
hardhat_case_weights: case_weights
Examples
data(Sacramento, package = "modeldata")
lapply(Sacramento, .get_data_types)
#> $city
#> [1] "factor" "unordered" "nominal"
#>
#> $zip
#> [1] "factor" "unordered" "nominal"
#>
#> $beds
#> [1] "integer" "numeric"
#>
#> $baths
#> [1] "double" "numeric"
#>
#> $sqft
#> [1] "integer" "numeric"
#>
#> $type
#> [1] "factor" "unordered" "nominal"
#>
#> $price
#> [1] "integer" "numeric"
#>
#> $latitude
#> [1] "double" "numeric"
#>
#> $longitude
#> [1] "double" "numeric"
#>