seqdur: Extract state durations from a sequence object.

View source: R/seqdur.R

seqdurR Documentation

Extract state durations from a sequence object.

Description

Extracts states durations from a sequence object. Returns a matrix containing the states durations for the sequences. The states durations in 'D-D-D-D-A-A-A-A-A-A-A-D' are 4,7,1. Distinct states can be extracted with the seqdss function.

Usage

seqdur(seqdata, with.missing=FALSE)

Arguments

seqdata

a sequence object as defined by the seqdef function.

with.missing

Should non-void missing values be considered as regular states? See Details.

Details

When with.missing=FALSE (default) missing values are ignored and a substring AA***A for example will be considered as a spell AAA of duration 3. When with.missing=TRUE, durations are also computed for spells of missing values (gaps in sequences).

See seqdef on options for handling missing values when creating sequence objects.

Value

a matrix containing the states durations for each distinct state in each sequence.

Author(s)

Alexis Gabadinho and Gilbert Ritschard

See Also

seqdss.

Examples

## Creating a sequence object from columns 13 to 24
## in the 'actcal' example data set
## Here we retain the first 10 sequences only.
data(actcal)
actcal.seq <- seqdef(actcal[1:10,13:24])

## Retrieving the spell durations
actcal.dur <- seqdur(actcal.seq)

## Displaying the durations for the first 10 sequences
actcal.dur

TraMineR documentation built on Sept. 19, 2023, 1:07 a.m.