list2DF: Create Data Frame From List

list2DFR Documentation

Create Data Frame From List

Description

Create a data frame from a list of variables.

Usage

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

Arguments

x

A list of variables for the data frame.

nrow

An integer giving the desired number of rows for the data frame, or NULL (default), in which case the maximal length of the elements of the list will be used. If necessary, list elements will be replicated to the same length given by the number of rows.

Details

Note that all list elements are taken “as is” (apart from possibly replicating to the same length).

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)