title: Calculating number and frequency of list elements in R?
body: <p>I've got a long list containing different numbers of elements which also can recur in the same field.<br>
  This is an example of the first five lines:  </p>
  
  <pre><code>A &lt;- list(c("JAMES","CHARLES","JAMES","RICHARD"),  
            c("JOHN","ROBERT","CHARLES"),  
            c("CHARLES","WILLIAM","CHARLES","MICHAEL","WILLIAM","DAVID","CHARLES","WILLIAM"),  
            c("CHARLES"),  
            c("CHARLES","CHARLES"))  
  </code></pre>
  
  <p>Now I'd like to calculate the number of elements for each line of the list.<br>
  My desired output would look similar to this:  </p>
  
  <pre><code>[1] 4  
  [2] 3  
  [3] 7  
  [4] 1  
  [5] 2  
  </code></pre>
  
  <p>In addition to that I'd like to know the frequency the term "CHARLES" occurs in each line.<br>
  Based on my example I'd like to get an output similar to this:  </p>
  
  <pre><code>[1] 1  
  [2] 1  
  [3] 3  
  [4] 1  
  [5] 2  
  </code></pre>
  
  <p>I thought of this:  </p>
  
  <pre><code>&gt; table(A)  
  Error in table(A) : all arguments arguments must have same length  
  &gt; sum(A)  
  Error in sum(A) : invalid 'type' (list) of argument  
  </code></pre>
  
  <p>But I don't know what to do about these error messages and am not aware of alternatives, unfortunately.<br>
  I know that the number of lines of the list is:  </p>
  
  <pre><code>&gt; length(A)  
  [1] 5  
  </code></pre>
  
  <p>But this doesn't answer my question, unfortunately. I couldn't find any other answers, either.<br>
  Therefore I'd like to ask you to please help me calculate these two measures!  </p>
  
  <p>Thank you very much in advance!  </p>