<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix"><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 ?<br>
      <br>
      <br>
      On 08/08/13 04:30, Ricardo Saporta wrote:<br>
    </div>
    <blockquote
cite="mid:CAE7Aa4SdmysbcACWouea-eoYHYEhc=q-+KTyFMKoLvHLzp_AHw@mail.gmail.com"
      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 moz-do-not-send="true"
                href="mailto:FErickson@psu.edu" target="_blank">FErickson@psu.edu</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc 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
                  moz-do-not-send="true"
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:0 0 0
                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 class="h5">On Wed, Aug 7, 2013 at 4:56 PM,
                      Ricardo Saporta <span dir="ltr"><<a
                          moz-do-not-send="true"
                          href="mailto:saporta@scarletmail.rutgers.edu"
                          target="_blank">saporta@scarletmail.rutgers.edu</a>></span>
                      wrote:<br>
                    </div>
                  </div>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div>
                      <div class="h5">
                        <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 moz-do-not-send="true"
                      href="mailto:datatable-help@lists.r-forge.r-project.org"
                      target="_blank">datatable-help@lists.r-forge.r-project.org</a><br>
                    <a moz-do-not-send="true"
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 class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
datatable-help mailing list
<a class="moz-txt-link-abbreviated" href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a>
<a class="moz-txt-link-freetext" href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a></pre>
    </blockquote>
    <br>
  </body>
</html>