My data looks like this
newdata
| APPLICATION | USER | APPLICANT |
|---|---|---|
| 25428X. | P991. | A1 |
| 25428X. | P929. | A2 |
| 26619L. | P929. | A1 |
| 26619L. | P991. | A2 |
This is what I am looking for
| APPLICATION | A1 | A2 |
|---|---|---|
| 25428X. | P991. | P929. |
| 26619L. | P929. | P991. |
I have tried the following but have faced issues with all of them: First try
library(tidyr)
wide<-newdata %>% spread(USER, APPLICANT, -c(APPLICATION))
Error: Each row of output must be identified by a unique combination of keys
Keys are shared for 944218 rows: 71988, ...*
Second try
reshape (newdata, idvar="APPLICANT", timevar="APPLICATION", direction="wide")
This code just does not load
Third try
library(tidyr)
newdata_wide<-spread(newdata, APPLICANT, USER)
Error: Each row of output must be identified by a unique combination of keys Keys are shared for 944410 rows: 71988, ...
Fourth try
pivot_wider(newdata, names_from="APPLICANT", values_from="USER", id_cols="APPLICATION")
Warning message: values are not uniquely identified; output will contain list-cols