Create a set of sets from a binary matrix where each row of the matrix is taken as one set.

as.famset(m, as.letters = TRUE)

Arguments

m

A binary matrix.

as.letters

logical, should the elements of the sets be letters or numbers?

Details

as.famset takes a binary matrix and converts it to a family (i.e. set) of sets where each row of the matrix represents one set and a "1" in row i and column j means that element j is contained in set i.

If as.letters is TRUE the elements of the sets are letters, otherwise numbers. However, if the matrix has colnames, these are taken as names for the elements of the sets taking precedence over the as.letters parameter.

If the matrix contains the same row multiple times it is contained only once in the resulting family of sets.

Value

An R object of class set containing sets..

See also

Examples

m <- matrix(c(1, 0, 0, 1, 1, 0), nrow = 2, ncol = 3) m
#> [,1] [,2] [,3] #> [1,] 1 0 1 #> [2,] 0 1 0
as.famset(m)
#> {{"b"}, {"a", "c"}}
as.famset(m, as.letters = FALSE)
#> {{2L}, {1L, 3L}}