如何解决使用combn函数创建表并根据其组合标记每个表
我有一些看起来像这样的数据
# A tibble: 10 x 7
XGBoost Logistic NN RandomForest SVMRadial SVMLinear LightGBM
<chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 Correct Correct Correct Correct Correct Correct Correct
2 Correct Correct Correct Correct Correct Correct Correct
我想为每个列组合创建一个表格。我可以做类似的事情:
combn(d,2,function(x){
table(x[[1]],x[[2]])
})
哪个给了我类似的东西
,1
[,1] [,2]
[1,] 8 0
[2,] 0 2,2
[,3
[,] 0 2
但是,我无法确定组合来自哪个表。我可以单独执行以下操作:
table(d$XGBoost,d$Logistic) %>%
matrix(
nrow = 2,dimnames = list("XGBoost" = c("Correct","Incorrect"),"Logistic" = c("Correct","Incorrect"))
)
哪个给:
Logistic
XGBoost Correct Incorrect
Correct 8 0
Incorrect 0 2
更多信息。
如何应用combn()
函数并获取每个组合名称,以使表格更具参考价值?
数据:
d <- structure(list(XGBoost = c("Correct","Correct","Incorrect","Correct"
),Logistic = c("Correct","Correct"),NN = c("Correct",RandomForest = c("Correct",SVMRadial = c("Correct",SVMLinear = c("Correct",LightGBM = c("Correct","Correct")),row.names = c(NA,-10L),class = c("tbl_df","tbl","data.frame"))
解决方法
也许尝试
Dim Cursor As XlMousePointer
Cursor = Application.Cursor
Application.Cursor = xlWait
-- YOUR CODE HERE --
Application.Cursor = Cursor
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。