View source: R/list_records_to_df.R
| list_records_to_df | R Documentation |
Converts a list where each element represents a record (row) into a
data.frame. Missing fields are filled with NA.
list_records_to_df(x)
x |
A list of records. Each record should be a named list or similar structure. Records may have different sets of fields. |
List-valued fields are flattened by collapsing their contents into a single character value. This guarantees that the returned data frame contains no list columns, but nested structure is not preserved.
This function is intended for row-oriented data structures, such as JSON arrays of objects.
A data.frame with one row per record and columns corresponding to the
union of all field names.
This function is written and documented with help from ChatGPT.
x <- list(
list(id = 1, name = "Ada", tags = list("a", "b")),
list(id = 2, name = "Bo"),
list(id = 3, name = "Cy", tags = list("x"))
)
list_records_to_df(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.