Learn R Programming

TraMineRextras (version 0.2.2)

STS_to_SPELL: Data conversion from STS to SPELL format.

Description

Convert data from STS to vertical SPELL format.

Usage

STS_to_SPELL(seqdata, id=NULL, pdata=NULL, birthdate=NULL, with.missing=TRUE)

Arguments

seqdata
a state sequence object of type "stslist" (see seqdef).
id
Either a vector of sequence id's or name of the id column in pdata. If NULL, rownames(seqdata) are used.
pdata
Data frame with id and birth dates.
birthdate
Either a vector of sequence birth dates or name of the birth date column in pdata.
with.missing
Logical. Should explicit spells of missing states be included?

Value

  • A data.frame with the sequences in vertical SPELL format.

Details

SPELL format is a vertical format with one row per spell, each spell being specified with four variables: an id, a begin date, a end date, and the state.

See Also

See Also seqformat.

Examples

Run this code
data(biofam)
biofam <- biofam[1:20,]

## Create the sequence object
bfstates <- c("Parent", "Left", "Married", "Left/Married", "Child",
            "Left/Child", "Left/Married/Child", "Divorced")
bf.shortlab <- c("P","L","M","LM","C","LC", "LMC", "D")
bf.seq <- seqdef(biofam[,10:25], alphabet=0:7, states=bf.shortlab, labels=bfstates)

spell <- STS_to_SPELL(bf.seq, birthdate=biofam$birthyr)
head(spell)

Run the code above in your browser using DataLab