我有一个数据框,其中行列名称
a <- c("Round_and_Centre", "Number", "Round")
b <- c("Round_and_Centre", "Number", "Round")
c <- c("Round_and_Centre", "Number", "Round")
我想检查每列中的名称是否与相同的列名称 fn 相同...如果它们相同,我需要重新绑定(bind)行以获取输出
我找不到检查列名并在列名相同时输出 true 的函数。如果输出为 true,则 rbind 它们
最佳答案
一个选项是
all(unlist(Map(`==`, list(a), list(b,c))))
或者使用combn
all(combn(c("a", "b", "c"),2, FUN = function(x) identical(get(x[1]), get(x[2]))))
关于r - 检查列名并绑定(bind)它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38391852/