R Under development (unstable) (2025-11-24 r89059 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > library("arulesSequences") Loading required package: arules Loading required package: Matrix Attaching package: 'arules' The following objects are masked from 'package:base': abbreviate, write Attaching package: 'arulesSequences' The following object is masked from 'package:arules': itemsets > > ### ceeboo 2008, 2016 > > data(zaki) > > z <- as(zaki, "timedsequences") > as(as(z, "sequences"), "data.frame") sequence sequenceID 1 <{C,D},{A,B,C},{A,B,F},{A,C,D,F}> 1 2 <{A,B,F},{E}> 2 3 <{A,B,F}> 3 4 <{D,G,H},{B,F},{A,G,H}> 4 > > s <- similarity(z) > s 4 x 4 sparse Matrix of class "dsCMatrix" 1 2 3 4 1 1.00 0.2 0.25 . 2 0.20 1.0 0.50 . 3 0.25 0.5 1.00 . 4 . . . 1 > all(s == similarity(z, z)) [1] TRUE > > as(s, "dist") 1 2 3 2 0.20 3 0.25 0.50 4 0.00 0.00 0.00 > > similarity(z, strict = TRUE) - s 4 x 4 sparse Matrix of class "dsCMatrix" 1 2 3 4 1 0 0 0 . 2 0 0 0 . 3 0 0 0 . 4 . . . 0 > > similarity(z, method = "dice") - s 4 x 4 sparse Matrix of class "dsCMatrix" 1 2 3 4 1 0.0000000 0.1333333 0.1500000 . 2 0.1333333 0.0000000 0.1666667 . 3 0.1500000 0.1666667 0.0000000 . 4 . . . 0 > similarity(z, method = "cosine") - s 4 x 4 sparse Matrix of class "dsCMatrix" 1 2 3 4 1 0.0000000 0.1535534 0.2500000 . 2 0.1535534 0.0000000 0.2071068 . 3 0.2500000 0.2071068 0.0000000 . 4 . . . 0 > > similarity(z, method = "subset", strict = TRUE) 4 x 4 sparse Matrix of class "dgCMatrix" 1 2 3 4 1 1.00 . . . 2 . 1.0 . . 3 0.25 0.5 1 . 4 . . . 1 > similarity(z, method = "subset") 4 x 4 sparse Matrix of class "dgCMatrix" 1 2 3 4 1 1.00 . . . 2 . 1.0 . . 3 0.25 0.5 1 . 4 . . . 1 > > is.subset(z) 4 x 4 sparse Matrix of class "lgCMatrix" 1 2 3 4 1 | . . . 2 . | . . 3 | | | . 4 . . . | > is.subset(z, proper = TRUE) 4 x 4 sparse Matrix of class "lgCMatrix" 1 2 3 4 1 . . . . 2 . . . . 3 | | . . 4 . . . . > > is.subset(z[3], z) 1 x 4 sparse Matrix of class "lgCMatrix" 1 2 3 4 3 | | | . > is.subset(z[3], z, proper = TRUE) 1 x 4 sparse Matrix of class "lgCMatrix" 1 2 3 4 3 | | . . > > is.superset(z) 4 x 4 sparse Matrix of class "lgCMatrix" 1 2 3 4 1 | . | . 2 . | | . 3 . . | . 4 . . . | > > is.superset(z[1], z) 1 x 4 sparse Matrix of class "lgCMatrix" 1 2 3 4 1 | . | . > > ### > > proc.time() user system elapsed 1.15 0.20 1.35