apply每行的最大值命名为对应最大值的列名

list <- data.frame(apply(x, 1, function(t) colnames(x)[which.max(t)]))
# 上文的t代表x中的1,即代表x中的行
apply(dataframe,1/0,fun)
fun是对行或者列说的
取出x的列名,选择某个index,这个index是这一行最大值对应的列的index

猜你喜欢

转载自blog.csdn.net/kylin_learn/article/details/81262908