title: Convert list with nested lists to one-row tibble with nested dataframe
body: <p>I'm trying to convert an object retrieved via an API and converted to a list by jsonlite into a single-row tibble (ie, each item in the list becomes a variable in the tibble).</p>
  
  <p>The complication is that aside from a set of individual values, the final item nested in the object is an array of objects, which jsonlite converts to a list of two lists, each containing two items (I used simplifyDataFrame = FALSE).</p>
  
  <p>A simplified structure resembling the actual API data is used in the reprex below.</p>
  
  
  
  <pre class="lang-r prettyprint-override"><code>library(tidyverse)
  
  dat &lt;- list(
    id = 1,
    name = "Jo Bloggs",
    offices = list(
      list(office_id = 999, title = "Vice President"),
      list(office_id = 998, title = "Director of Operations")
    )
  )
  
  df &lt;- dat %&gt;% as_tibble()
  df
  #&gt; # A tibble: 2 x 3
  #&gt;      id name      offices   
  #&gt;   &lt;dbl&gt; &lt;chr&gt;     &lt;list&gt;    
  #&gt; 1  1.00 Jo Bloggs &lt;list [2]&gt;
  #&gt; 2  1.00 Jo Bloggs &lt;list [2]&gt;
  </code></pre>
  
  <p>Created on 2018-02-26 by the <a href="http://reprex.tidyverse.org" rel="nofollow noreferrer">reprex package</a> (v0.2.0).</p>
  
  <p>Converting using as_tibble() produces a two-row data frame duplicating all of the non-nested values, with the two nested lists each on a separate row.</p>
  
  <p>What should I change so that instead of this, I end up with a single row of data and the final column contains a nested 2 x 2 dataframe/tibble? Thanks in advance.</p>