Apriori.Basket {do}R Documentation

Convert vector to sparse matrix

Description

Convert vector or dataframe to sparse matrix.

Usage

Apriori.Basket(x, sep = ";", dup.delete = FALSE)

Arguments

x

a vector

sep

one separator

dup.delete

whether to delete duplicated values in the same row, default is FALSE

Value

a sparse matrix

Examples

# convert a vector to sparse matrix
g=c('a,b,a,,','a,b,c,d','d,c,f,g,h')
Apriori.Basket(x=g,sep = ',')

# convert a dataframe to sparse matrix
library(data.table)
df=fread(text = '
t1 t2 t3
a NA d
g a j')
Apriori.Basket(x=df,sep = ',')

[Package do version 2.0.0.0 Index]