Skip to contents

Incidence matrix to list

Usage

im2list(x, empty = list(NA, "", 0, FALSE), ...)

Arguments

x

matrix where non-empty values indicate presence of each element (row) in each set (column).

empty

list of values recognized as empty. Each item is co-erced to the class in columns of x.

...

additional arguments are ignored.

Details

This function is the reciprocal to list2im(). This function will also convert a signed incidence matrix to a normal list, removing the directional sign.

Examples

setlist <- make_venn_test(100, 3, do_signed=TRUE)
ims <- list2im_value(setlist);
print(head(ims));
#>          set_A set_B set_C
#> item_067    -1     0     0
#> item_042     1     0     0
#> item_050     1     0    -1
#> item_043    -1     0     0
#> item_014    -1     0     0
#> item_025     1    -1     0

# convert back to list
im_value2list(ims);
#> $set_A
#> item_067 item_042 item_050 item_043 item_014 item_025 item_090 item_091 
#>       -1        1        1       -1       -1        1       -1       -1 
#> item_069 item_093 item_057 item_009 item_072 item_026 item_007 item_099 
#>       -1        1        1       -1        1        1       -1       -1 
#> item_089 item_083 item_036 item_078 item_097 item_076 item_015 item_032 
#>       -1        1        1        1        1        1       -1        1 
#> item_086 item_084 item_041 item_023 item_027 item_060 item_053 item_079 
#>        1        1       -1        1       -1        1        1       -1 
#> 
#> $set_B
#> item_025 item_069 item_093 item_072 item_089 item_097 item_076 item_027 
#>       -1       -1        1        1       -1       -1        1       -1 
#> item_053 item_096 item_038 item_034 item_063 item_013 item_082 item_021 
#>        1        1       -1       -1        1        1        1       -1 
#> 
#> $set_C
#> item_050 item_090 item_091 item_072 item_086 item_041 item_060 item_079 
#>       -1       -1        1        1        1       -1        1       -1 
#> item_047 item_095 item_016 item_006 item_039 item_031 item_081 
#>        1        1        1       -1        1       -1        1 
#> 
im2list(ims);
#> $set_A
#>  [1] "item_067" "item_042" "item_050" "item_043" "item_014" "item_025"
#>  [7] "item_090" "item_091" "item_069" "item_093" "item_057" "item_009"
#> [13] "item_072" "item_026" "item_007" "item_099" "item_089" "item_083"
#> [19] "item_036" "item_078" "item_097" "item_076" "item_015" "item_032"
#> [25] "item_086" "item_084" "item_041" "item_023" "item_027" "item_060"
#> [31] "item_053" "item_079"
#> 
#> $set_B
#>  [1] "item_025" "item_069" "item_093" "item_072" "item_089" "item_097"
#>  [7] "item_076" "item_027" "item_053" "item_096" "item_038" "item_034"
#> [13] "item_063" "item_013" "item_082" "item_021"
#> 
#> $set_C
#>  [1] "item_050" "item_090" "item_091" "item_072" "item_086" "item_041"
#>  [7] "item_060" "item_079" "item_047" "item_095" "item_016" "item_006"
#> [13] "item_039" "item_031" "item_081"
#>