Hey everyone,

I'm very new with Rstudio and still struggling a lot. I have a dataframe that looks like this:

Patient ID - Disease number - Treatment

p001 - d001 - treatment A

p001 -d001 - treatment B

p002 -d002 - treatment C

So to clarify, patient 1 got two treatments (treatment A and treatment B) for the same disease (d001) and patient 2 got one treatment (treatment C) for another disease (d002).

How do I get this dataframe to only have 1 disease number in a column and then different treatments in the same row. So a bit more like this:

Disease number - patient ID - treatment

d001 - p001 - treatment A, treatment B

d002 - p002 - treatment C

Can anyone help me? Thanks in advance!