title: R remove empty (nchar = 0) elements from list of lists
body: <p>I have a list of lists/vectors:</p>
  
  <pre><code>list(c("cat1", "cat6", ""), c("cat5", "cat3", "cat4"), c("cat6", 
  "cat4", ""), c("cat5", "cat1", "cat2", "cat4"), c("cat6", "cat3", 
  "cat2"))
  </code></pre>
  
  <p>and I'm looking an elegant way to remove inner elements with nchar=0 like the 3rd element in the first list (with value "").
  I have tried:</p>
  
  <pre><code>l[lapply(l,length)&gt;0] 
  </code></pre>
  
  <p>but that does not apply to the inner elements length but to the external list elements length.
  The expected output is:</p>
  
  <pre><code>list(c("cat1", "cat6"), c("cat5", "cat3", "cat4"), c("cat6", 
      "cat4"), c("cat5", "cat1", "cat2", "cat4"), c("cat6", "cat3", 
      "cat2")) 
  </code></pre>
  
  <p>Any help appreciated</p>