title: Using Dplyr and Tidyr within a Function to Capitalize First and Last Names in a Dataframe Column
body: <pre><code>Names &lt;- c("SUSAN,ALTOP","Brent,SPINER","KIM,YAMAGUCHI","John,McMurphy","Kevin,Y")
  City &lt;- c("Toronto","New York","Chicago","Toronto","Tokyo")
  DF &lt;- data.frame(Names,City)
  </code></pre>
  
  <p>I'm hoping to create a function that will capitalize the first and last names in the simple example data frame above so that the names read as "Susan Altop","Brent Spiner"...etc. (Notice that I've also removed the commas.)</p>
  
  <p>I can accomplish this using the following codes, either separately or with piping. But I'm hoping to create a function since I'll have to do this many times, but I'm not sure how to do that when using dplyr, tidyr, etc. I'm also open to more creative suggestions that use lists and purrr, if possible. </p>
  
  <pre><code>DF &lt;- DF %&gt;% separate(DF,Names,c("First","Last",sep=","),remove=TRUE)
  DF &lt;- DF %&gt;% mutate_each(funs(tolower),First,Last)
  DF &lt;- DF %&gt;% mutate_each(funs(Capitalize),First,Last)
  DF &lt;- DF %&gt;% mutate(NewNames=paste0(First," ",Last)
  </code></pre>