Skip to contents

generate a matrix to show whether the item in each element of a list

Usage

exist_matrix(x, n_lim = 0, n_top = NULL, sort_items = NULL)

Arguments

x

list of character vectors

n_lim

n limit to keep items in result

n_top

only keep top n items in result

sort_items

function to sort the items, item frequency by default

Value

tibble

Examples

x <- 1:5 %>% purrr::map(
  ~ gen_char(to = "k", n = 5, random = TRUE, seed = .x)
)
exist_matrix(x)
#> # A tibble: 5 × 11
#>   g     i     k     a     b     c     d     e     f     h     j    
#> * <lgl> <lgl> <lgl> <lgl> <lgl> <lgl> <lgl> <lgl> <lgl> <lgl> <lgl>
#> 1 TRUE  TRUE  FALSE TRUE  TRUE  FALSE TRUE  FALSE FALSE FALSE FALSE
#> 2 FALSE FALSE FALSE TRUE  FALSE FALSE FALSE TRUE  TRUE  TRUE  FALSE
#> 3 TRUE  FALSE FALSE FALSE FALSE FALSE TRUE  TRUE  FALSE FALSE TRUE 
#> 4 TRUE  FALSE TRUE  FALSE FALSE TRUE  FALSE FALSE FALSE TRUE  FALSE
#> 5 FALSE TRUE  TRUE  FALSE TRUE  FALSE FALSE FALSE FALSE FALSE FALSE