list_to_matrix: Convert a list of vectors to a binary matrix

View source: R/list-to-matrix.R

list_to_matrixR Documentation

Convert a list of vectors to a binary matrix

Description

Convert a list of sets into a binary matrix.

Usage

list_to_matrix(sets)

Arguments

sets

named list of sets (vectors) to be converted to binary matrix.

Value

binary matrix with a column for each set. rownames of the matrix represent the union of all sets. A '1' indicates the inclusion of the element in the set.

Examples

sets <- list(
  "set1" = letters[1:5],
  "set2" = letters[2:6],
  "set3" = letters[1:7]
)

list_to_matrix(sets)

jcalendo/coriell documentation built on March 5, 2025, 5:42 a.m.