Description Usage Arguments Details Value Author(s) Examples
Convert a list of vectors (or data frames) with same numbered lengths (or number of columns) into a data frame.
1 2 |
vList |
List of vectors, data frames, or lists. See Details. |
col.names |
Optional character vector of length |
row.names |
Optional character vector with length equivalent to the
length of |
convert.numeric |
If |
strings.as.factors |
If |
If the elements of vList
are vectors, each vector must have the same
length, n
, and the resulting data frame will have n
columns.
If the elements of vList
are data frames, each data frame must have the
same structure (though they may have differing numbers of rows).
If the elements of vList
are lists, each list is first converted to a data frame
via as.data.frame
and the resulting data frames must have the
same structure (though they may have differing numbers of rows).
It is permissible for vList
to contain NULL
elements.
list2df
performs numerous consistency checks to ensure that contents
of vList
which are combined into the resulting data frame are
conformable, labeled consistently, of the equivalent class when necessary,
etc.
If vList
is list of data frames, a data frame resulting from
efficiently row binding the data frames in vList
is returned. If
vList
is a list of vectors, a data frame is returned where the first
column contains the first elements of the list vectors, the second column
contains the second elements of the list vectors, etc.
Landon Sego
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # For a list of vectors
x <- c("r1c1 1", "r2c1 2", "r3c1 3", "r4c4 4")
y <- strsplit(x, "\ ")
y
list2df(y)
list2df(y, col.names = LETTERS[1:2])
# Here's another list of vectors
z <- list(NULL, a = c(first = 10, second = 12), NULL, b = c(first = 15, second = 17))
z
list2df(z)
# For a list of data frames
z <- list(d1 = data.frame(a = 1:4, b = letters[1:4]),
d2 = data.frame(a = 5:6, b = letters[5:6]))
z
list2df(z)
# A list of lists
z <- list(list(a = 10, b = TRUE, c = "hi"), list(a = 12, b = FALSE, c = c("there", "bye")))
z
list2df(z)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.