list2im: Convert list to incidence matrix

list2imR Documentation

Convert list to incidence matrix

Description

Convert list to incidence matrix

Usage

list2im(x, makeUnique = TRUE, verbose = FALSE, ...)

Arguments

x

list of character vectors.

makeUnique

logical indicating whether to enforce uniqueness on each vector in the list. If makeUnique=FALSE and there are duplicated values, then the resulting incidence matrix will be updated to reflect the count of each element.

verbose

logical indicating whether to print verbose output.

Details

This function uses some very efficient methods from the arules package to convert a list of items into an incidence matrix. The conversion creates a transactions object, which takes advantage of the efficient code, then extracts the matrix from that object. Unfortunately, that object class does not permit counting each item, though it may be possible through another method.

The incidence matrix will have rownames matching list elements, and colnames match the list names.

In future the uniqueness step may be carried out using S4Vectors list methods, which are also highly efficient specifically in handling very large lists.

See Also

Other jam list functions: intercalate()

Examples

set.seed(123);
l1 <- list(first=sample(letters, 10),
   second=sample(letters, 15),
   third=sample(letters, 5));
list2im(l1);


jmw86069/jambio documentation built on April 21, 2024, 2:48 p.m.