例如:
require(reshape2)
var1 = c(rep('john', 3), rep('aron', 2), 'frank')
var2 = c('john', 'aron', 'frank', 'aron', 'frank', 'frank')
var3 = rnorm(6)
mydat = data.frame(var1, var2, var3)
acast(mydat, var1~var2)
结果:
Using var3 as value column: use value.var to override.
aron frank john
aron 0.32026 0.22858 NA
frank NA 0.57658 NA
john 0.30543 1.16453 -2.0021
这弄乱了原始顺序,理想情况下,人们希望在下三角形中很好地看到 3 个 NA。