title: R: Separate a column with multiple values into separate binary columns
body: <p>I have a column in a dataset that is <em>fairly</em> messy. 
  It is a column called: <code>Themes</code>, in a dataset of different projects. </p>
  
  <p>There are in total 10 different themes, all jumbled up in a random order 
  Image:<a href="https://i.stack.imgur.com/6jlnu.png" rel="nofollow noreferrer">My messy column</a></p>
  
  <p>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. </p>
  
  <p>fx. please see image:<a href="https://i.stack.imgur.com/ZHelm.png" rel="nofollow noreferrer">My wished output</a></p>
  
  <p>What I have tried to do is use separate:  </p>
  
  <pre><code>Themes_split &lt;- Merge %&gt;%
                 separate(Themes, into = c("CP", "CG", 
                        "Edu", "Health", "Nut", "Ill", "Liv", "Hum", 
                        "Cross-Thematic", "Non-Thematic"), sep = ",", 
                         na.rm=TRUE)
  </code></pre>
  
  <p>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: <a href="https://i.stack.imgur.com/hENuA.png" rel="nofollow noreferrer">My actual output</a></p>
  
  <p>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??</p>
  
  <p>I am looking forward to a bit of help - Thank you</p>