0

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)
Z.Lin
  • 28,055
  • 6
  • 54
  • 94
  • This already has a very detailed explanation [over here](https://stackoverflow.com/a/45898919/1335174). Essentially, you need to help `spread` (which btw is now superseded by `pivot_wider`) by creating at least one other column in your df that (together with "Pseudo_ID" uniquely identifies each row – alex_jwb90 Sep 15 '20 at 23:55
  • Thanks I already worked it out :) – estefanía betancur Oct 06 '20 at 08:36

0 Answers0