My data:
data=cbind(c(1,1,2,1,1,3),c(1,1,2,1,1,1),c(2,2,1,2,1,2)) colnames(data)=paste(\"item\",1:3) rownames(data)=paste(\"method\",1:6)
I wan
You can try this, base R:
R
res=apply(data,2,function(u) as.numeric(names(sort(table(u), decreasing=T))[1])) setNames(lapply(unique(res), function(u) names(res)[res==u]), unique(res)) #$`1` #[1] "item 1" "item 2" #$`2` #[1] "item 3"