title: create dummy variable from string variable
body: <p>I am trying to create a dummy variable from a column variable from an existing data set. The variable I am interested in is a title in this format: </p>
  
  <p>CHEMICALS - Commission Delegated Directive (EU) 2015/863 of 31 March 2015 amending Annex II to Directive 2011/65/EU of the European Parliament and of the Council as regards the list of restricted substances (Text with EEA relevance)</p>
  
  <p>or</p>
  
  <p>Commission Implementing Directive (EU) 2015/2392... </p>
  
  <p>I want to create a dummy variable indicating that the Title is either implementing or delegated. In other words, when the word "delegated" is in my title variable, this will be labeled 1 and everything else will be labeled 0. </p>
  
  <p>Can anyone help me with this? It is very appreciated. So far, I have used this code: </p>
  
  <pre><code>infringements$delegated &lt;- ifelse(infringements$Title=="Delegated", 1, 0)
  table(infringements$delegated, infringements$Title)  
  summary(infringements$delegated)
  </code></pre>
  
  <p>When I run the code, I get 0 matches, even though I know that there are 41 matches.</p>