當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。