convert signed incidence matrix to list
Usage
imSigned2list(x, empty = c(NA, "", 0, FALSE), ...)Arguments
- x
matrixor equivalent object withcolnames(x)indicating list set names, andrownames(x)indicating list contents.- empty
charactervector of incidence matrix values that should be considered "empty" and therefore do not indicate the row inxis present for the given column inx. All other items are considered to be present, and are assigned direction based upon the value in that cell ofx.- ...
additional arguments are ignored.
Value
list of named numeric vectors, where list names
are defined by colnames(x), and vector names are derived
from rownames(x). Values in each vector indicate the
signed direction, c(-1,1).
Details
This function converts an signed incidence matrix
that contains positive and negative values, or equivalent
data.frame, to a list of named vectors containing values
c(-1, 1) to indicate signed direction.
The input matrix should contain numeric values where
positive and negative values indicate directionality.
When the input contains only logical values c(TRUE,FALSE)
the direction is assumed to be +1 positive.
Values of NA are converted to zero 0 and therefore ignored.
Values that are logical with TRUE and FALSE are converted
to numeric before output.
See also
Other jam list functions:
colors_from_list(),
im2list(),
im2list_dep(),
imSigned2list_dep(),
list2concordance(),
list2im(),
list2imSigned()
Examples
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);
#> A B C
#> a 0 1 -1
#> b 1 1 0
#> c -1 NA 1
# matrix input
im2list(im);
#> $A
#> [1] "b" "c"
#>
#> $B
#> [1] "a" "b"
#>
#> $C
#> [1] "a" "c"
#>
imSigned2list(im);
#> $A
#> b c
#> 1 -1
#>
#> $B
#> a b
#> 1 1
#>
#> $C
#> a c
#> -1 1
#>
imSigned2list(im != 0);
#> $A
#> b c
#> 1 1
#>
#> $B
#> a b
#> 1 1
#>
#> $C
#> a c
#> 1 1
#>