match-methods {arulesSequences}R Documentation

Match Objects

Description

match finds the positions of first matches of a collection of sequences or sequence rules in an object of the same class.

%in% indicates matches of the left in the right operand. If the right operand is a vector of item labels indicates if a sequence contains any of the items given.

%ain% indicates if a sequence contains all the items given as the right operand.

%pin% indicates if a sequence contains any item matching the regular expression given as the right operand.

%ein% indicates if a sequence contains any itemset containing all the items given as the right operand.

duplicated indicates duplicate occurrences of sequences or sequence rules.

Usage

## S4 method for signature 'sequences,sequences'
match(x, table, nomatch = NA_integer_, incomparables = NULL)

## S4 method for signature 'sequencerules,sequencerules'
match(x, table, nomatch = NA_integer_, incomparables = NULL)

## S4 methods for signature 'sequences, character':
x %in%  table
x %ain% table
x %pin% table
x %ein% table

## S4 method for signature 'sequences'
duplicated(x, incomparables = FALSE)

## S4 method for signature 'sequencerules'
duplicated(x, incomparables = FALSE)

Arguments

x

an object.

table

an object (of the same class as x).

nomatch

the value to be returned in the case of no match.

incomparables

not used.

Value

For match returns an integer vector of the same length as x containing the position in table of the first match, or if there is no match the value of nomatch.

For %in%, %ain%, and %pin% returns a logical vector indicating for each element of x if a match was found in the right operand.

For duplicated a logical vector corresponding with the elements of x.

Note

For practical reasons, the item labels given in the right operand must match the item labels associated with x exactly.

Currently, an operator for matching against the labels of a set of sequences is not provided. For example, it could be defined as

"%lin%" <- function(l, r) match(r, labels(l)) > 0

with the caveat of being too general.

FIXME currently matching of timed sequences does not take event times into consideration.

Author(s)

Christian Buchta

See Also

Class sequences, sequencerules, method labels, itemLabels.

Examples

## continue example
example(cspade)

## match
labels(s1[match(s2, s1)])
labels(s1[s1 %in% s2])	    # the same

## match items
labels(s2[s2 %in%  c("B", "F")])
labels(s2[s2 %ain% c("B", "F")])
labels(s2[s2 %pin% "F"])

## match itemsets
labels(s1[s1 %ein% c("F","B")])

[Package arulesSequences version 0.2-25 Index]