当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


R recipes get_data_types 获取在食谱中使用的类型

.get_data_types() 泛型在内部用于为配方中使用的列提供类型。这些函数是用户在 selections 中看到的工作的基础。

用法

.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)

参数

x

一个东西

细节

此函数充当 class() 的扩展 recipes-specific 版本。通过忽略相似类型的差异("double"和"numeric")并允许每个元素具有多种类型("factor"返回"factor"、"unordered"和"nominal","character"返回"string", "unordered" 和 "nominal")我们能够创建更自然的选择器,例如 all_nominal()all_string()all_integer()

以下列表显示了配方定义的不同类的数据类型。如果对象具有 .get_data_types() 不支持的类,它将获得数据类型 "other"。

  • 字符:字符串、无序和名义

  • ordered:有序的,名义上的

  • 因子:因子、无序因子和名义因子

  • 整数:整数和数字

  • 数字:双精度和数字

  • double:双精度和数字

  • 生存:生存

  • 逻辑性:逻辑性

  • 日期: 日期

  • POSIXct:日期时间

  • 列表:列表

  • textrecipes_tokenlist:令牌列表

  • hardhat_case_weights:case_weights

也可以看看

例子


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"
#> 

相关用法


注:本文由纯净天空筛选整理自Max Kuhn等大神的英文原创作品 Get types for use in recipes。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。