Create Data Frame From List (original) (raw)

list2DF {base} R Documentation

Description

Create a data frame from a list of variables.

Usage

list2DF(x = list(), nrow = 0)

Arguments

x A list of same-length variables for the data frame.
nrow An integer giving the desired number of rows for the data frame in case x gives no variables (i.e., has length zero).

Details

Note that all list elements are taken “as is”.

Value

A data frame with the given variables.

See Also

[data.frame](../../base/help/data.frame.html)

Examples

## Create a data frame holding a list of character vectors and the
## corresponding lengths:
x <- list(character(), "A", c("B", "C"))
n <- lengths(x)
list2DF(list(x = x, n = n))

## Create data frames with no variables and the desired number of rows:
list2DF()
list2DF(nrow = 3L)

[Package _base_ version 4.6.0 Index]