title: Digit sum function in R
body: <p>I was looking for the quite basic numeric function <a href="http://en.wikipedia.org/wiki/Digit_sum" rel="noreferrer">digit sum</a> in R.</p>
  
  <ul>
  <li>I did not find a preinstalled function. </li>
  <li>Even in Stackoverflow's
  extensive R library I did not find a record.</li>
  </ul>
  
  <p>Therefore tried myself ending with following function:</p>
  
  <pre><code># Function to calculate a digit sum
  digitsum = function (x) {sum(as.numeric(unlist(strsplit(as.character(x), split="")))) }
  </code></pre>
  
  <p>I works, but I still struggle with following two questions:</p>
  
  <ol>
  <li>Is there really in plain R no function for digit sum?</li>
  <li>Is there a smarter way to code this function?</li>
  </ol>