Description Usage Arguments Value See Also Examples
View source: R/json_unnest_wider.R
Unnest a column of JSON objects in a data frame producing a wider data frame.
1 2 3 4 5 6 7 8 9 10 | json_unnest_wider(
data,
col,
ptype = list(),
names_sort = FALSE,
names_sep = NULL,
names_repair = "check_unique",
wrap_scalars = FALSE,
bigint_as_char = bigint_default()
)
|
data |
A data frame. |
col |
JSON-column of arrays to extract components from. |
ptype |
Output type. If |
names_sort |
Should the extracted columns be sorted by name? If |
names_sep |
If |
names_repair |
What happens if the output has invalid column names? |
wrap_scalars |
A named list of
|
bigint_as_char |
Convert big integers to character? The option
|
A data frame, or subclass of data frame of the same length as data
.
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 | # turn all components of item into columns with json_unnest_wider()
tibble::tibble(
id = 1:2,
x = c(
'{"name": "Peter", "age": 19}',
'{"age": 37}'
)
) %>%
json_unnest_wider(x)
# sort names and specify proto types
tibble::tibble(
id = 1:2,
x = c(
'{"name": "Peter", "age": 19, "purchase_ids": [1, 2]}',
'{"age": 37, "purchase_ids": []}'
)
) %>%
json_unnest_wider(
x,
ptype = list(
age = integer(),
name = character(),
purchase_id = new_json_array()
),
names_sort = TRUE
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.