title: R - How to create a data frame from a data frame with conditions?
body: <p>I have a data frame that has many columns, but I want to create another data frame that only has the columns race and spouse. I have this sample of data.</p>
  
  <pre><code>  gender name    race realm  spouse
  1  Female Adanel  Men  Gondor  Not Married
  2  Male   Lagduf  Orc  Mordor  Married
  2  Male   Boromir Men  Gondor  Married
  </code></pre>
  
  <p>I would like to create another data frame with race and spouse (where the creature is "married") so that I can plot a graph from it showing the marriage variation between races. The only data that should appear in the new data frame would be the following one:</p>
  
  <pre><code>  race spouse
  1 Orc  Married
  2 Men  Married
  </code></pre>
  
  <p>I would like to get the columns race and spouse(where the creature is "Married"). I have tried something like this:</p>
  
  <pre><code>marriedCreatures &lt;- data %&gt;% filter(spouse == "Married" &amp; race) 
  </code></pre>
  
  <p>As I've recently started working with R I don't know how I am supposed to create this new data frame from other data frame's columns.</p>
  
  <p>I would appreciate if anyone could help me with that.</p>
  
  <p>Thanks!</p>