title: Recursive R function to flatten hierarchical json dataset
body: <p>I have a json file that looks like this:</p>
  <pre><code>{
    &quot;data&quot;: [
      {
        &quot;sense&quot;: &quot;a_lot.r.01&quot;,
        &quot;frequency&quot;: 20,
        &quot;level&quot;: 0,
        &quot;childrenSenses&quot;: []
      },
      {
        &quot;sense&quot;: &quot;succeed.v.01&quot;,
        &quot;frequency&quot;: 64,
        &quot;level&quot;: 0,
        &quot;childrenSenses&quot;: [
          {
            &quot;sense&quot;: &quot;achieve.v.01&quot;,
            &quot;frequency&quot;: 21,
            &quot;level&quot;: 1,
            &quot;childrenSenses&quot;: [
              {
                &quot;sense&quot;: &quot;reach.v.07&quot;,
                &quot;frequency&quot;: 12,
                &quot;level&quot;: 2,
                &quot;childrenSenses&quot;: []
              },
              {
                &quot;sense&quot;: &quot;come_to.v.03&quot;,
                &quot;frequency&quot;: 5,
                &quot;level&quot;: 2,
                &quot;childrenSenses&quot;: []
              }
            ]
          },
          {
            &quot;sense&quot;: &quot;pull_off.v.03&quot;,
            &quot;frequency&quot;: 14,
            &quot;level&quot;: 1,
            &quot;childrenSenses&quot;: []
          },
          {
            &quot;sense&quot;: &quot;arrive.v.02&quot;,
            &quot;frequency&quot;: 10,
            &quot;level&quot;: 1,
            &quot;childrenSenses&quot;: []
          },
          {
            &quot;sense&quot;: &quot;work.v.03&quot;,
            &quot;frequency&quot;: 15,
            &quot;level&quot;: 1,
            &quot;childrenSenses&quot;: []
          }
        ]
      }
    ]
  }
  </code></pre>
  <p>I need a recursive function that will build a single dataframe that contains 4 fields out of a json file of this structure with any number of levels of parent-child relationships:</p>
  <p>the dataframe will have 4 fields described as:</p>
  <p>id: contains the value of &quot;sense&quot;<br />
  label: also contains the value of &quot;sense&quot;<br />
  parent: contains the value of the parent &quot;sense&quot;<br />
  value: contains the value of the &quot;frequency&quot; for the sense</p>