im2list | R Documentation |
convert incidence matrix to list
im2list(x, empty = c(NA, "", 0, FALSE), ...)
x |
|
empty |
|
... |
additional arguments are ignored. |
This function converts an incidence matrix
, or equivalent
data.frame
, to a list. The matrix
should contain either
numeric values such as c(0, 1)
, or logical values such
as c(TRUE,FALSE)
, otherwise values are considered either
zero == FALSE
, or non-zero == TRUE
.
The resulting list will be named by colnames(x)
of the input,
and will contain members named by rownames(x)
which are
either non-zero, or contain TRUE
.
Values of NA
are converted to zero 0
and therefore ignored.
list
of character vectors
, where list names
are defined by colnames(x)
, and list elements are vectors
that contain values from rownames(x)
.
Other jam list functions:
colors_from_list()
,
im2list_dep()
,
imSigned2list_dep()
,
imSigned2list()
,
list2concordance()
,
list2imSigned()
,
list2im()
im <- matrix(c(0,1,-1,1,1,NA,-1,0,1),
ncol=3,
nrow=3,
dimnames=list(letters[1:3], LETTERS[1:3]))
print(im);
# matrix input
im2list(im);
# data.frame
imdf <- data.frame(im);
print(imdf);
im2list(im);
# logical input
imtf <- (!im == 0);
print(imtf);
im2list(imtf);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.