title: Create new character column in R data frame based on existing character vector
body: <p>I am new to R and am stuck on what seems like an easy task - create new column vector in R data frame conditional on an existing character vector. </p>
  
  <p>As an example, I have a data frame, "class", with one character column ("Names") and one numeric column ("Student_numbers"): </p>
  
  <pre><code>Names &lt;- c("Sarah", "Mary", "Ben", "Will", "Alex") 
  Student_numbers &lt;- c(3,5,6,7,7)
  class &lt;- data.frame(Names, Student_numbers) 
  </code></pre>
  
  <p>To the data frame "class", I would like to add a new character column called "Gender" which is based on values in the character vector, "Names": </p>
  
  <pre><code>Male &lt;- c("Ben", "Will", "Alex") 
  Female &lt;- c("Sarah", "Mary") 
  
   Names    Student_numbers  Gender
  1 Sarah   3                Female
  2 Mary    5                Female
  3 Ben     6                Male
  4 Will    7                Male
  5 Alex    7                Male
  </code></pre>
  
  <p>Instead of doing this manually, I would like to do it automatically based on the character vectors defined above. </p>
  
  <p>Thank you in advance for your help. </p>