title: Convert JSON to data.frame with more than 2 columns
body: <p>I am trying to properly convert a JSON to a data.frame with 3 columns.</p>
  
  <p>This is a simplification of my data</p>
  
  <pre><code># simplification of my real data
  my_data &lt;- '{"Bag 1": [["bananas", 1], ["oranges", 2]],"Bag 2": [["bananas", 3], ["oranges", 4], ["apples", 5]]}'
  
  library(jsonlite)
  
  my_data &lt;- fromJSON(my_data)
  
  &gt; my_data
  $`Bag 1`
       [,1]      [,2]
  [1,] "bananas" "1" 
  [2,] "oranges" "2" 
  
  $`Bag 2`
       [,1]      [,2]
  [1,] "bananas" "3" 
  [2,] "oranges" "4" 
  [3,] "apples"  "5" 
  </code></pre>
  
  <p>I try to convert that to a data.frame</p>
  
  <pre><code># this return an error about "arguments imply differing number of rows: 2, 3"
  my_data &lt;- as.data.frame(my_data)
  
  &gt; my_data &lt;- as.data.frame(my_data)
  Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
    arguments imply differing number of rows: 2, 3
  </code></pre>
  
  <p>This is my solution to create the data.frame</p>
  
  <pre><code># my solution 
  my_data &lt;- data.frame(fruit = do.call(c, my_data),
    bag_number = rep(1:length(my_data), 
    sapply(my_data, length)))
  
  # how it looks
  my_data
  
  &gt; my_data
           fruit bag_number
  Bag 11 bananas          1
  Bag 12 oranges          1
  Bag 13       1          1
  Bag 14       2          1
  Bag 21 bananas          2
  Bag 22 oranges          2
  Bag 23  apples          2
  Bag 24       3          2
  Bag 25       4          2
  Bag 26       5          2
  </code></pre>
  
  <p>But my idea is to obtain something like this to avoid problems like doing <code>my_data[a:b,1]</code> when I want to use ggplot2 and others.</p>
  
  <pre><code>fruit   | quantity | bag_number
  oranges | 2        | 1
  bananas | 1        | 1
  oranges | 4        | 2
  bananas | 3        | 2
  apples  | 5        | 2
  </code></pre>