title: R - count number of list components
body: <p>I know that in R, you can index through a list with double brackets, i.e. <code>mylist[[1]]</code>. How do you count the number of elements in that list (not the number of elements in each list item, but the maximum <code>n</code> in <code>mylist[[n]]</code>)? I tried <code>NROW</code>, <code>NCOL</code>, <code>dim</code>, among others.</p>
  
  <p>Some example code for the desired behavior of some function <code>num.items(list)</code>:</p>
  
  <pre><code>require(testthat)
  mylist &lt;- list(array(rnorm(4),dim=c(2,2)),array(rnorm(4),dim=c(2,2)))
  
  expect_that( num.items(mylist), equals(2) )
  </code></pre>