nested_list_to_tibble: Turn a nested list into a tibble

Description Usage Arguments Value Examples

View source: R/nested_list_to_tibble.R

Description

This function will take a nested list and make it into a tibble. This can be helpful with nested lists that have varying structures and depths.

Usage

1
nested_list_to_tibble(.list, col_names = "col_")

Arguments

.list

A list object.

col_names

A character. String that represents the names of the columns after the transformation

Value

A tibble

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
## Not run: 
json <- '
{
  "stuff": {
    "buried": {
      "deep": [
        {
          "location": "here",
          "name": "Laura DeCicco",
          "super_power": "fixing merge conflicts",
          "other_secret_power": []
        },
        {
          "location": "here",
          "name": "Amanda Dobbyn",
          "super_power": "flight",
          "more_nested_stuff": 4
        }
      ],
      "alsodeep": 2342423234,
      "stilldeep": {
        "even_deeper": [
          {
            "location": "not here",
            "name": "Jim Hester",
            "super_power": []
          },
          {
            "location": "here",
            "name": "Christine Stawitz",
            "super_power": "invisibility",
            "more_nested_stuff": 5
          },
          {
            "location": "here",
            "name": "Isabella Velasquez",
            "super_power": "teleportation"
          }
        ]
      }
    }
  }
}'

my_list <- jsonlite::fromJSON(json)

data <- nested_list_to_tibble(my_list)

## End(Not run)

KoderKow/kowr documentation built on July 19, 2021, 4:18 p.m.