Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you don't need names and your list is one level deep, then if you can beat</p> <pre><code>.Internal(unlist(your_list, FALSE, FALSE)) </code></pre> <p>I will vote up everything you do on SO for the next 1 year!!!</p> <p>[Update: if non-unique names are needed and the list is not recursive, here is a version which improves over the unlist 100 times</p> <pre><code> myunlist &lt;- function(l){ names &lt;- names(l) vec &lt;- unlist(l, F, F) reps &lt;- unlist(lapply(l, length), F, F) names(vec) &lt;- rep(names, reps) vec } myunlist(list(a=1:3, b=2)) a a a b 1 2 3 2 &gt; tl &lt;- list(a = 1:20000, b = 1:5000, c = 2:30) &gt; system.time(for(i in 1:200) unlist(tl)) user system elapsed 22.97 0.00 23.00 &gt; system.time(for(i in 1:200) myunlist(tl)) user system elapsed 0.2 0.0 0.2 &gt; system.time(for(i in 1:200) unlist(tl, F, F)) user system elapsed 0.02 0.00 0.02 </code></pre> <p>]</p> <p>[Update2: Responce to challenge Nr3 from Richie Cotton. </p> <pre><code>bigList3 &lt;- replicate(500, rnorm(1e3), simplify = F) unlist_vit &lt;- function(l){ names(l) &lt;- NULL do.call(c, l) } library(rbenchmark) benchmark(unlist = unlist(bigList3, FALSE, FALSE), rjc = unlist_rjc(bigList3), vit = unlist_vit(bigList3), order = "elapsed", replications = 100, columns = c("test", "relative", "elapsed") ) test relative elapsed 1 unlist 1.0000 2.06 3 vit 1.4369 2.96 2 rjc 3.5146 7.24 </code></pre> <p>]</p> <p>PS: I assume a "big fish" is the one with more reputation than you. So I am pretty much small here :). </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload