【发布时间】:2021-09-20 04:23:50
【问题描述】:
周五晚上,我正在努力解决这个问题。 我的数据是这样的
df <- data.frame(teamA=c("Italy","Italy","England","England"),
teamB=c("Germany","Greece","Germany","Greece"), win=c(0,1,1,1))
df
teamA teamB win
1 Italy Germany 0
2 Italy Greece 1
3 England Germany 1
4 England Greece 1
我想把它转换成一个像这样的矩阵。最好使用 dplyr,但我很绝望,没关系
Italy England
Germany 0 1
Greece 1 1
【问题讨论】:
标签: r matrix dplyr aggregate tidyverse