title: Finding the length of each string within a column of a data-frame in R
body: <p>I wish to calculate the number of characters of every string of the <code>name</code> column. My dataframe <code>sample</code> is as shown below :</p>
  
  <pre><code>date        name           expenditure      type
  23MAR2013   KOSH ENTRP     4000             COMPANY
  23MAR2013   JOHN DOE       800              INDIVIDUAL
  24MAR2013   S KHAN         300              INDIVIDUAL
  24MAR2013   JASINT PVT LTD 8000             COMPANY
  25MAR2013   KOSH ENTRPRISE 2000             COMPANY
  25MAR2013   JOHN S DOE     220              INDIVIDUAL
  25MAR2013   S KHAN         300              INDIVIDUAL
  26MAR2013   S KHAN         300              INDIVIDUAL
  </code></pre>
  
  <p>Why is that <code>nchar</code> giving me a list of random numbers? So is <code>str_length()</code> from <code>stringr</code> package</p>
  
  <pre><code>Length &lt;- aggregate(nchar(sample$name), by=list(sample$name), FUN=nchar)
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>         Group.1       x
  1 JASINT PVT LTD       2
  2       JOHN DOE       1
  3     JOHN S DOE       2
  4     KOSH ENTRP       2
  5 KOSH ENTRPRISE       2
  6         S KHAN 1, 1, 1
  </code></pre>
  
  <p>Desired Output :</p>
  
  <pre><code>     Group.1       x
  1 JASINT PVT LTD       14
  2       JOHN DOE       8
  3     JOHN S DOE       10
  4     KOSH ENTRP       10
  5 KOSH ENTRPRISE       14
  6         S KHAN       6
  </code></pre>
  
  <hr>
  
  <p>The csv for the above table :</p>
  
  <pre><code>"Date","name","expenditure","type"
  "23MAR2013","KOSH ENTRP",4000,"COMPANY"
  "23MAR2013 ","JOHN DOE",800,"INDIVIDUAL"
  "24MAR2013","S KHAN",300,"INDIVIDUAL"
  "24MAR2013","JASINT PVT LTD",8000,"COMPANY"
  "25MAR2013","KOSH ENTRPRISE",2000,"COMPANY"
  "25MAR2013","JOHN S DOE",220,"INDIVIDUAL"
  "25MAR2013","S KHAN",300,"INDIVIDUAL"
  "26MAR2013","S KHAN",300,"INDIVIDUAL"
  </code></pre>