2
說我有包含的因素矢量的列表:可能是這樣的哪個指標矩陣非排他性因素
colors <- c("red", "green", "blue")
f <- factor(colors, levels=colors)
rgb <- sapply(sample(1:3, 5, replace=TRUE), function(n) sample(f, n))
:
> invisible(sapply(rgb, function(x) print(x, max.levels=0)))
[1] blue green
[1] red
[1] blue red green
[1] red blue green
[1] blue
我如何構建指標值的矩陣代表相同的信息:
[,1] [,2] [,3]
[1,] 0 1 1
[2,] 1 0 0
[3,] 1 1 1
[4,] 1 1 1
[5,] 0 0 1
雖然我的問題可能與鏈接的問題類似,但我相信@ akrun解決我的問題比其他問題中的任何答案都要簡單得多。 – user12341234