Learn R Programming

arulesSequences (version 0.2-1)

match-methods: 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

## S3 method for class 'sequences,sequences':
match(x, table, nomatch = NA_integer_, incomparables = NULL)

## S3 method for class '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

## S3 method for class 'sequences': duplicated(x, incomparables = FALSE)

## S3 method for class '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.

See Also

Class sequences, sequencerules, method labels, itemLabels.

Examples

Run this code
## 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")])

Run the code above in your browser using DataLab