Learn R Programming

TraMineR (version 2.2-10)

alphabet: 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

Value

For ‘alphabet’ a character vector containing the alphabet.

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

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?

Author

Alexis Gabadinho and Gilbert Ritschard

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.

See Also

seqdef

Examples

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

Run the code above in your browser using DataLab