我有5個矢量的每個項目在這些載體多於2個向量之間進行比較或者爲「是」或「否」 因此,我希望這些5個載體(逐行)之間進行比較,並計算出對每一行進行多數投票並將結果添加到新的向量中。 如何以有效的方式執行此操作。在R(表決)
v1=c("yes","no","no","yes")
v2=c("no","no","yes","yes")
v3=c("yes","yes","no","yes")
v4=c("yes","no","yes","yes")
v5=c("yes","yes","yes","no")
#The expected output is "yes", "no", "yes", "yes"
它的工作原理也如果數據存儲爲因素,因爲這將是一個「標準」 data.frame的情況下 – Gilles