Turning all table elements into column IDs then new table 0 or 1 if the patient (row ID) had that element

Can you provide a reproducible example of your dataset?