alphabet: Get or set the alphabet of a state or event sequence object

View source: R/alphabet.R

alphabetR Documentation

Get or set the alphabet of a state or event sequence object

Description

For state sequences, the function gets or sets the (short) labels associated to the states in the alphabet of a state sequence object (the list of all possible states). The get form also applies to event sequences, while the set form does not work with event sequences.

Usage

alphabet(seqdata, with.missing=FALSE)
alphabet(seqdata) <- value

Arguments

seqdata

a state sequence object of class stslist as defined with the seqdef function or, for the get form only, an event sequence object as defined with seqecreate or a probabilistic suffix tree generated with the PST package.

value

For state sequences only. Vector of characters of the same length as the vector returned by the alphabet function, i.e. one label for each state in the alphabet.

with.missing

Logical. When seqdata is a state sequence object (stslist), should the returned alphabet include the nr symbol standing for missing states?

Details

A state sequence object—created with the seqdef function—stores sequences as a matrix where columns are factors. The levels of the factors include the alphabet plus the codes for missing values and void elements. The alphabet function retrieves or sets the “alphabet” attribute of the state sequence object. The state names composing the alphabet are preferably short labels, since they are used for printing sequences. Longer labels for describing more precisely each state in legend are stored in the “labels” attribute of the sequence object.

For an event sequence object—created with seqecreate—the get form of alphabet works as an alias for levels. The set form alphabet <- does not work and should not be used.

Value

For ‘alphabet’ a character vector containing the alphabet.

For ‘alphabet <-’ the updated state sequence object.

Author(s)

Alexis Gabadinho and Gilbert Ritschard

See Also

seqdef

Examples

## Creating a sequence object with the columns 13 to 24
## in the 'actcal' example data set
data(actcal)
actcal.seq <- seqdef(actcal,13:24)

## Retrieving the alphabet
alphabet(actcal.seq)

## Setting the alphabet
alphabet(actcal.seq) <- c("FT", "PT", "LT", "NO")

## Event sequences
actcal.eseq <- seqecreate(actcal.seq)
alphabet(actcal.eseq)

TraMineR documentation built on Dec. 1, 2022, 5:08 p.m.