Description Usage Arguments Value Examples
Converts a list to a data frame, with names in multiple columns.
1 2 | list_to_data.frame(l, name_variables = "names", values_variable = "values",
stringsAsFactors = getOption("stringsAsFactors"))
|
l |
A variable, probably a list. |
name_variables |
A string. What should the columns formed from
the names of |
values_variable |
A string. What should the columns formed from
the values of |
stringsAsFactors |
Should character columns be converted to factors? |
data.frame
.
1 2 3 4 5 6 7 8 9 10 | (l <- list(
a = 1,
2:3, # missing names are blank
c = list(ca = 4:6, 7:10, list(cca = 11:15)),
d = list() # empty elt's silently ignored
))
list_to_data.frame(l)
# Custom column names
list_to_data.frame(l, c("group", "subgroup", "element"), "amount")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.