0

So essentially I am working on a project for my undergraduate thesis regarding candidate vote percentage in each South Florida Precinct. Right now the data frame looks something like this

[Precinct][CountyCode][Candidate][VoteTotal]

A101...........BRO................Biden...........408

A101...........BRO................Trump...........330

A101...........BRO................Other.............29

When I would actually prefer to make the data look like this

[Precinct][CountyCode][TrumpVote][BidenVote][OtherVote]

A101...............BRO...............330..............408...............29

Any idea how to make that work?

Gregor Thomas
  • 119,032
  • 17
  • 152
  • 277
  • Something like `tidyr::pivot_wider(your_data, names_from = Candidate, values_from = VoteTotal)`. The linked FAQ shows other methods and examples, but I'd recommend focusing on the answer demonstrating `pivot_wider`. If you need more help than that, please edit your question to show what you've tried with `pivot_wider` and provide data in a nice copy/pasteable format, e.g., `dput(your_data[1:6, ])` for a reproducible version of the first 6 rows. – Gregor Thomas Feb 26 '22 at 00:38

0 Answers0