尽管尝试了reshape,table,xtabs,dplyr和其他功能的变化,我还是试图让它工作。有人可以帮我把下面的数据框转换成带有指标变量的数据框吗?
我正在处理的数据框(请注意谷歌列出两次,因为它有两个功能):
0
我正在寻找的结果(注意谷歌列出了两个功能):
df = data.frame(domain=c("google","google","yahoo","microsoft"),
feature=c("a","b","a","c"))
我能来的最接近的是dcast,但没有将变量重新编码为二进制指标:
dfResult = data.frame(domain=c("google","yahoo","microsoft"),
feature_a=c("1","1","0"),
feature_b=c("1","0","0"),
feature_c=c("0","0","1")
)