title: Capitalize with dplyr
body: <p>I am doing data cleaning with dplyr.
  One of the things I want to do is to capitalize values in certain columns.</p>
  
  <pre><code>    data$surname
      john
      Mary
      John
      mary
      ...
  </code></pre>
  
  <p>I suppose I have to use the <strong>mutate</strong> function of dplyr with something like this</p>
  
  <pre><code>    titleCase &lt;- function(x) {
      + s &lt;- strsplit(as.character(x), " ")[[1]]
      + paste(toupper(substring(s, 1, 1)), substring(s, 2),
      + sep = "", collapse = " ")
      + }
  </code></pre>
  
  <p>But how to combine both? I get all kinds of errors or truncated data frames</p>
  
  <p>Thanks</p>