list2DF {base}R Documentation

Create Data Frame From List

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

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.3.0 Index]