title: How can I extract from title from name in a column?
body: <p>I have a column of names of the form "Hobs, Mr. jack" i.e. lastname, title. firstname. title has 4 types -"Mr.", "Mrs.","Miss.","Master." How can I search for each item in the column &amp; return the title ,which I can store in another column ?</p>
  
  <pre><code>Name &lt;- c("Hobs, Mr. jack","Hobs, Master. John","Hobs, Mrs. Nicole",........)
  </code></pre>
  
  <p>desired output - a column "title" with values - <code>("Mr","Master", "Mrs",.....)</code></p>
  
  <p>I have tried something like this:</p>
  
  <pre><code>f &lt;- function(d) {
        if (grep("Mr", d$title)) {
                    gsub("$Mr$", "Mr", d$title, ignore.case = T)
             }
   }
  </code></pre>
  
  <p>no success >.&lt;</p>