<div dir="ltr"><div>Matthew, </div><div><br></div><<<span style="font-family:arial,sans-serif;font-size:13px">Rick - are you asking for use cases of list columns full stop or use cases of converting nested lists to data.table containing list columns ?>></span><div>
<font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">The Latter.   Specifically, in the last example you give</font></div><div><span style="font-family:arial,sans-serif;font-size:13px">   > L = list(1,2,3,list("a",4L,3:10)) </span><span style="font-family:arial,sans-serif;font-size:13px">   # the one nested list here creates one list column</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">   > as.data.table(L)</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">     V1 V2 V3           V4 </span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">  1:  1  2  3            a</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">  2:  1  2  3            4</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">  3:  1  2  3 3,4,5,6,7,8,</span><br style="font-family:arial,sans-serif;font-size:13px"></div><div><font face="arial, sans-serif"><br></font><div class="gmail_extra">
In the example above, we are essentially creating a tuple between each element in the sublist (what becomes V4) and all other elements in L. </div><div class="gmail_extra"><br></div><div class="gmail_extra">I am curious as to what this might reflect in real life?  I often encounter the opposite need, for example, the sublist being a group of sub-properties.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">My intuition is that is that sublist is clearly grouped and so should most probably be treated as such.  If anything, I would think of expanding the sublist horizontally into additional columns. </div>
<div class="gmail_extra"><br></div><div class="gmail_extra">And if I understand correctly, when the number of elements in the sublist is the same as the length of all the other elements of the main list, then the sublist's groups are preserved, correct? </div>
<div class="gmail_extra">eg: </div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">    L2 = list( 1:2 , 11:12, 31:32, list(c("a", "b", "c"), c("q","r","s")) )</div>
<div class="gmail_extra">    as.data.table(L2)</div><div class="gmail_extra"><span class="" style="white-space:pre">    </span>#    V1 V2 V3    V4</div><div class="gmail_extra"><span class="" style="white-space:pre">  </span># 1:  1 11 31 a,b,c</div>
<div class="gmail_extra"><span class="" style="white-space:pre">      </span># 2:  2 12 32 q,r,s</div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">My curiosity about use cases is mostly for learnings sake  </div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><div style="font-size:13px">
Cheers, </div><div style="font-size:13px">Rick</div><div><br></div></div></div>
<br><br><div class="gmail_quote">On Thu, Aug 8, 2013 at 12:38 AM, Matthew Dowle <span dir="ltr"><<a href="mailto:mdowle@mdowle.plus.com" target="_blank">mdowle@mdowle.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div><br>
      Agreed, intentional.<br>
      <br>
      > L = list(1,2,3)<br>
      > as.data.table(L)<br>
         V1 V2 V3             #  3 columns, not one list column<br>
      1:  1  2  3<br>
      <br>
      > L = list(1,2,3,list("a",4L,3:10))    # the one nested list
      here creates one list column<br>
      > as.data.table(L)<br>
         V1 V2 V3           V4<br>
      1:  1  2  3            a<br>
      2:  1  2  3            4<br>
      3:  1  2  3 3,4,5,6,7,8,<br>
      <br>
      Rick - are you asking for use cases of list columns full stop or
      use cases of converting nested lists to data.table containing list
      columns ?<div><div class="h5"><br>
      <br>
      <br>
      On 08/08/13 04:30, Ricardo Saporta wrote:<br>
    </div></div></div><div><div class="h5">
    <blockquote type="cite">
      <div dir="ltr">Hey Frank, 
        <div><br>
        </div>
        <div>Thanks for pointing out that SO link, I had missed it. </div>
        <div><br>
        </div>
        <div>All, </div>
        <div><br>
        </div>
        <div>I'm curious as to which used cases this functionality would
          be used in (used for?)</div>
        <div><br>
        </div>
        <div>thanks, </div>
        <div>Rick </div>
        <div><br>
        </div>
        <div class="gmail_extra">
          <br>
          <br>
          <div class="gmail_quote">On Wed, Aug 7, 2013 at 8:14 PM, Frank
            Erickson <span dir="ltr"><<a href="mailto:FErickson@psu.edu" target="_blank">FErickson@psu.edu</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
              <div>Hi Rick,</div>
              <div><br>
              </div>
              <div>I guess it's intentional: Matthew saw this SO
                question (since he edited one of the answers): <a href="http://stackoverflow.com/questions/9547518/creating-a-data-frame-where-a-column-is-a-list" target="_blank">http://stackoverflow.com/questions/9547518/creating-a-data-frame-where-a-column-is-a-list</a></div>

              <div><br>
              </div>
              <div>Some musings: Of course, to reproduce
                as.data.frame-like behavior, you can un-nest the list,
                so both functions treat it the same way.</div>
              <div><br>
              </div>
              <blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
                <div>Z <- unlist(Y,recursive=FALSE)</div>
                <div><br>
                </div>
                <div>
                  <div>identical(as.data.table(Z),as.data.table(as.data.frame(Z)))
                    # TRUE</div>
                </div>
                <div>
                  <div># or, equivalently (?)</div>
                </div>
                <div>
                  <div>identical(do.call(data.table,Z),data.table(do.call(data.frame,Z)))
                    # TRUE</div>
                </div>
              </blockquote>
              <div><br>
              </div>
              <div>On the other hand, going back the other direction
                (getting data.table-like behavior when data.frame's is
                the default) is more awkward, as seen in that SO
                question (where they mention protecting each sublist
                with the I() function). Besides, I'm with @flodel, who
                asked the SO question, in expecting data.table's
                behavior: one top-level item in the list mapping to one
                column in the result...</div>
              <div><br>
              </div>
              <div>--Frank</div>
              <div><br>
                <div class="gmail_quote">
                  <div>
                    <div>On Wed, Aug 7, 2013 at 4:56 PM,
                      Ricardo Saporta <span dir="ltr"><<a href="mailto:saporta@scarletmail.rutgers.edu" target="_blank">saporta@scarletmail.rutgers.edu</a>></span>
                      wrote:<br>
                    </div>
                  </div>
                  <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                    <div>
                      <div>
                        <div dir="ltr">
                          <div>Hi all, <br>
                          </div>
                          <div><br>
                          </div>
                          <div>Note the following discrepancy in
                            structure between as.data.frame &
                            as.data.table when called on a nested list.</div>
                          <div>as.data.frame converts the sublist into
                            individual columns whereas as.data.table
                            stacks them into a single column and creates
                            additional rows. </div>
                          <div><br>
                          </div>
                          <div>Is this intentional? </div>
                          <div>-Rick</div>
                          <div><br>
                          </div>
                          <div><br>
                          </div>
                          <div>
                            <div>as.data.frame(X)</div>
                            <div>#        start       type      end
                              data.editDist data.second</div>
                            <div># 1 start_node is_similar end_node    
                                      1  HelloWorld</div>
                            <div><br>
                            </div>
                            <div>as.data.table(X)</div>
                            <div>#         start       type      end    
                                data</div>
                            <div># 1: start_node is_similar end_node    
                                   1</div>
                            <div># 2: start_node is_similar end_node
                              HelloWorld</div>
                          </div>
                          <div>
                            <br>
                          </div>
                          <div><br>
                          </div>
                          <div><br>
                          </div>
                          <div><br>
                          </div>
                          <div>### Copy+Paste'able Below ###</div>
                          <div><br>
                          </div>
                          <div># Example 1:</div>
                          <div>X <-  structure(list(start =
                            "start_node", type = "is_similar", end =
                            "end_node", </div>
                          <div>    data = structure(list(editDist = 1,
                            second = "HelloWorld"), .Names =
                            c("editDist", </div>
                          <div>    "second"))), .Names = c("start",
                            "type", "end", "data"))</div>
                          <div><br>
                          </div>
                          <div>as.data.frame(X)<br>
                          </div>
                          <div>as.data.table(X)</div>
                          <div><br>
                          </div>
                          <div>as.data.table(as.data.frame(X))</div>
                          <div><br>
                          </div>
                          <div><br>
                          </div>
                          <div># Example 2, with more elements:</div>
                          <div>Y <- structure(list(start =
                            c("start_node", "start_node"), type =
                            c("is_similar", "is_similar"), end =
                            c("end_node", "end_node"), data =
                            structure(list(editDist = c(1, 1), second =
                            c("HelloWorld", "HelloWorld")), .Names =
                            c("editDist", "second"))), .Names =
                            c("start", "type", "end", "data"))</div>
                          <div><br>
                          </div>
                          <div>as.data.frame(Y)</div>
                          <div>as.data.table(Y)</div>
                          <div><br>
                          </div>
                        </div>
                        <br>
                      </div>
                    </div>
                    _______________________________________________<br>
                    datatable-help mailing list<br>
                    <a href="mailto:datatable-help@lists.r-forge.r-project.org" target="_blank">datatable-help@lists.r-forge.r-project.org</a><br>
                    <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br>
                  </blockquote>
                </div>
                <br>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
datatable-help mailing list
<a href="mailto:datatable-help@lists.r-forge.r-project.org" target="_blank">datatable-help@lists.r-forge.r-project.org</a>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a></pre>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br></div></div></div>