I have a column in a dataset that is fairly messy.
It is a column called: Themes
, in a dataset of different projects.
There are in total 10 different themes, all jumbled up in a random order Image:My messy column
What I am trying to do, is create a column for each theme, where either 0 (= project does not include a theme) or 1 (= project does include a theme), is placed as to whether the specific project/row contains the theme.
fx. please see image:My wished output
What I have tried to do is use separate:
Themes_split <- Merge %>%
separate(Themes, into = c("CP", "CG",
"Edu", "Health", "Nut", "Ill", "Liv", "Hum",
"Cross-Thematic", "Non-Thematic"), sep = ",",
na.rm=TRUE)
But the output of this does not recognize the random order of how the themes are listed in the column, please see image of output: My actual output
How do I make R recognize the different themes and assign the value 0 or 1 to the new columns for when the specific project contains the different themes??
I am looking forward to a bit of help - Thank you