I have this data with two variables, and I would like to convert the Atc-codes in wide format, creating multiple rows per patient (Pseudo_ID
).
The code that I am using is below, but I get this error
1: Each row of output must be identified by a unique combination of keys. Keys are shared for 594871 rows
library(tidyr)
Meds18_wide <- spread(MEDS18, key = Pseudo_ID, value = Atc_code)