rbindList | R Documentation |
rbind a list of vectors into matrix or data.frame
rbindList(
x,
emptyValue = "",
nullValue = NULL,
keepListNames = TRUE,
newColnames = NULL,
newRownames = NULL,
fixBlanks = TRUE,
returnDF = FALSE,
verbose = FALSE,
...
)
x |
|
emptyValue |
|
nullValue |
optional value used to replace NULL entries in
the input list, useful especially when the data was produced
by |
keepListNames |
|
newColnames |
NULL or |
newRownames |
NULL or |
fixBlanks |
|
returnDF |
|
verbose |
|
The purpose of this function is to emulate do.call(rbind, x)
on a list
of vectors, while specifically handling when there are different
numbers of entries per vector. The output matrix
number of columns
will be the longest vector (or largest number of columns) in the
input list x
.
Instead of recycling values in each row to fill the target number
of columns, this function fills cells with blank fields,
with default argument fixBlanks=TRUE
.
In extensive timings tests at the time this function was created,
this technique was notably faster than alternatives.
It runs do.call(rbind, x)
then subsequently replaces recycled values
with blank entries, in a manner that is notably faster than
alternative approaches such as pre-processing the input data.
matrix
unless returnDF=TRUE
in which the output is coerced
to a data.frame
.
The rownames by default are derived from the list names,
but the colnames are not derived from the vector names.
If input x
contains data.frame
or matrix
objects, the output
will retain those values.
Other jam list functions:
cPasteSU()
,
cPasteS()
,
cPasteUnique()
,
cPasteU()
,
cPaste()
,
heads()
,
jam_rapply()
,
list2df()
,
mergeAllXY()
,
mixedSorts()
,
relist_named()
,
rlengths()
,
sclass()
,
sdim()
,
uniques()
,
unnestList()
L <- list(a=LETTERS[1:4], b=letters[1:3]);
rbindList(L);
rbindList(L, returnDF=TRUE);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.