我正在尝试获取如下所示的数据:
Precinct Office Votes
1 auditor 10
1 president 9
2 auditor 6
2 president 8
有3列,precinct
,auditor
和president
,其值为现在Votes
。我尝试过使用dplyr::spread()
,但结果却是这样的:
Precinct auditor president
1 10 NA
1 NA 9
2 6 NA
2 NA 8
如何摆脱交错的NA
以便我有一半的行,如下所示:
Precinct auditor president
1 10 9
2 6 8