I have the following data set:
df <- data.frame(identifier = c("a","b","b","c"),
disease = c("heart, lung","lung, heart,,","lung, heart, heart, liver", "kidney, brain "))
which gives:
identifier disease
1 a heart, lung
2 b lung, heart,,
3 b lung, heart, heart, liver
4 c kidney, brain
I want to be able to then go through the diseases, and for every condition create a new column. If the disease is present for a specific identifier, I want to then put a "yes" in that column. So the ideal output would be:
identifier heart lung liver kidney brain
1 a Yes Yes No No No
2 b Yes Yes No No No
3 b Yes Yes Yes No No
4 c No No No Yes Yes
Would greatly appreciate any help with this as it has stumped me for a couple of hours now :)