# times-methods: Compute Time Statistics of Sequences In arulesSequences: Mining Frequent Sequences

## Description

Computes the gaps, the minimum or maximum gap, or the span of sequences.

## Usage

 ```1 2``` ```## S4 method for signature 'timedsequences' times(x, type = c("times", "gaps", "mingap", "maxgap", "span")) ```

## Arguments

 `x` an object. `type` a string value specifying the type of statistic.

## Value

If `type = "items"` returns a list of vectors of events times corresponding with the elements of a sequence.

If `type = "gaps"` returns a list of vectors of time differences between consecutive elements of a sequence.

Otherwise, a vector corresponding with the elements of `x`.

## Note

Gap statistics are not defined for sequences of size one, i.e. which contain a single element. `NA` is used for undefined values.

FIXME lists are silently reduced to vector if possible.

## Author(s)

Christian Buchta

Class `sequences`, `timedsequences`, method `size`, `itemFrequency`, `timeFrequency`.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12``` ```## continue example example("timedsequences-class") ## times(z) times(z, "gaps") ## all defined times(z, "span") ## crosstab table(size = size(z), span = times(z, "span")) ```

### Example output

```Loading required package: arules

Attaching package: 'arules'

The following objects are masked from 'package:base':

abbreviate, write

tmdsq-> ## use example data
tmdsq-> data(zaki)

tmdsq-> ## coerce
tmdsq-> z <- as(zaki, "timedsequences")

tmdsq-> z
set of 4 timedsequences

tmdsq-> ## get time sequences
tmdsq-> summary(timesets(z))
itemMatrix in sparse format with
4 rows (elements/itemsets/transactions) and
4 columns (items) and a density of 0.625

most frequent items:
10      20      15      25 (Other)
3       3       2       2       0

element (itemset/transaction) length distribution:
sizes
1 2 3 4
1 1 1 1

Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
1.00    1.75    2.50    2.50    3.25    4.00

includes extended item information - examples:
labels eventID
1     10      10
2     15      15
3     20      20

tmdsq-> ## coerce back
tmdsq-> as(z, "transactions")
transactions in sparse format with
10 transactions (rows) and
8 items (columns)
[[1]]
[1] 10 15 20 25

[[2]]
[1] 15 20

[[3]]
[1] 10

[[4]]
[1] 10 20 25

[[1]]
[1] 5 5 5

[[2]]
[1] 5

[[3]]
[1] NA

[[4]]
[1] 10  5

[1] 15  5  0 15
span
size 0 5 15
1 1 0  0
2 0 1  0
3 0 0  1
4 0 0  1
```

arulesSequences documentation built on July 2, 2020, 4:09 a.m.