title: How to Create a Dataframe With A List of Uneven Lists
body: <p>I am working with some API data that outputs in a JSON file. The main problem with this data is that using the function <code>fromJSON</code>, I get a "list of lists" that looks like this (<code>head</code> applied):</p>
  
  <pre><code>[[1]]
  [[1]]$`agency_code`
  [1] 7
  
  [[1]]$applicant_income_000s
  [1] 56
  
  [[1]]$action_taken
  [1] 1
  
  [[1]]$as_of_year
  [1] 2015
  
  
  [[2]]
  [[2]]$`agency_code`
  [1] 9
  
  [[2]]$applicant_income_000s
  [1] 27
  
  [[2]]$action_taken
  [1] 1
  
  [[2]]$as_of_year
  [1] 2015
  
  
  [[3]]
  [[3]]$`agency_code`
  [1] 9
  
  [[3]]$applicant_income_000s
  [1] 90
  
  [[3]]$action_taken
  [1] 1
  
  [[3]]$as_of_year
  [1] 2015
  
  
  [[4]]
  [[4]]$`agency_code`
  [1] 9
  
  [[4]]$action_taken
  [1] 1
  
  [[4]]$as_of_year
  [1] 2015
  </code></pre>
  
  <p>As you can see, <code>$applicant_income_000s</code> is missing in the 4th list element (and in many more).</p>
  
  <p>I want to make a <code>dataframe</code> where the missing elements are coded. The problem I am running into is with <code>rbind</code>. Here's what I've tried so far:</p>
  
  <ol>
  <li><code>df &lt;- as.data.frame(json.list.data)</code></li>
  <li><code>df &lt;- rbind.data.frame(json.list.data, deparse.level = 1)</code></li>
  <li><code>df &lt;- as.data.frame(rbind(json.list.data, deparse.level = 1)</code></li>
  </ol>
  
  <p>Ideally, the API query would have included fields for missing values, such as <code>applicant_income_000s = .</code>, but it does not. Instead, it omits the field, yielding uneven lists which are the root of my problem!</p>
  
  <p>Does anyone have an idea for this problem? I really appreciate your time!</p>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>Here is a sample of my list data, from <code>dput(head())</code>:</p>
  
  <pre><code>list(list(agency_code = 7, applicant_income_000s = 56, action_taken = 1, 
  as_of_year = 2015), list(agency_code = 9, applicant_income_000s = 27, 
  action_taken = 1, as_of_year = 2015), list(agency_code = 9, 
  applicant_income_000s = 90, action_taken = 1, as_of_year = 2015), 
  list(agency_code = 9, action_taken = 1, as_of_year = 2015), 
  list(agency_code = 5, applicant_income_000s = 212, action_taken = 1, 
      as_of_year = 2015), list(agency_code = 7, action_taken = 1, 
      as_of_year = 2015))
  </code></pre>