I am working with a dataset that includes case numbers and employee names. Sometimes multiple employee names are tied to a single case number, or an employee may show attached to multiple case numbers. This shows on a series of rows like so:
| Case.Number | Employee Name |
|---|---|
| 001 | Name 1 |
| 001 | Name 2 |
| 002 | Name 3 |
| 003 | Name 2 |
I'm using pivot_wider to rearrange this dataset from long to wide, but as this is a very large dataset it generates 100+ additional columns to account for all the Employee Names.
Is there a way to instead have only a few additional columns generated, into which any Employee Names associated with a Case.Number will populate? Intended output something like this:
| Case.Number | Employee Name 1 | Employee Name 2 | Employee Name 3 |
|---|---|---|---|
| 001 | Name 1 | Name 2 | NA |
| 002 | Name 3 | NA | NA |
| 003 | Name 2 | NA | NA |
Is this possible?
