I want the first dataset to change into the second. I tried attempting dcast() from reshape2 library but I'm not successful with it. How I may achieve such a dataframe transformation in R?
Given dataframe
date | employee | outcome |
---|---|---|
jan1 | Alex | 200 |
jan2 | Alex | 210 |
jan3 | Alex | 167 |
jan1 | Tom | 212 |
jan2 | Tom | 222 |
jan3 | Tom | 189 |
jan1 | Kim | 210 |
jan2 | Kim | 210 |
jan3 | Kim | 208 |
Desired dataframe
employee | jan1 | jan2 | jan3 |
---|---|---|---|
Alex | 200 | 210 | 167 |
Tom | 212 | 222 | 189 |
Kim | 210 | 210 | 208 |