list2im_opt | R Documentation |
Optimized conversion of list to incidence matrix
list2im_opt(setlist, empty = 0, do_sparse = FALSE, ...)
setlist |
|
empty |
default single value used for empty/missing entries,
the default |
do_sparse |
|
... |
additional arguments are ignored. |
This function rapidly converts a list of vectors into
an incidence matrix whose rownames are items, and colnames
are the names of the input list. The default output
do_sparse=TRUE
returns a logical
matrix class ngCMatrix
from the Matrix
package. When do_sparse=FALSE
the
output is a matrix
class with numeric
values 0
and 1
.
Note that the rows in the output matrix are not sorted, since the step of sorting item names may take several seconds when working with a list whose vectors contain millions of items. For sorted rows, the best remedy is to run this function, the re-order rownames afterward.
matrix
object with value c(0, 1)
when do_sparse=FALSE
(default), or when do_sparse=TRUE
, it returns a Matrix
object
class "CsparseMatrix"
with logical
values, only when
Matrix
is available.
Other venndir conversion:
counts2setlist()
,
im2list()
,
im_value2list()
,
list2im_value()
,
overlaplist2setlist()
,
signed_counts2setlist()
setlist <- list(A=c("one", "two", "three"),
b=c("two", "one", "four", "five"));
list2im_opt(setlist);
list2im_opt(setlist, do_sparse=TRUE);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.