HSPELL_to_STS: Data conversion from Horizontal Spell to STS.

View source: R/HSPELL_to_STS.R

HSPELL_to_STSR Documentation

Data conversion from Horizontal Spell to STS.

Description

Convert data from Horizontal Spell to STS.

Usage

HSPELL_to_STS(seqdata, begin, end, status = NULL,
    fixed.status = NULL, pvar = NULL, overwrite = TRUE,
    fillblanks = NULL, tmin = NULL, tmax = NULL, id = NULL,
    endObs = NULL)

Arguments

seqdata

a data frame or matrix containing sequence data.

begin

Vector containing the columns (name or number) with the beginning position of each spell.

end

Vector containing the columns (name or number) with the end position of each spell.

status

Vector containing the columns (name or number) with the status of each spell.

fixed.status

Default status (for period not covered by any spell.)

pvar

names or numbers of the column containing the 'birth' time.

overwrite

Should the most recent episode overwrite the older one when they overlap? If FALSE, the most recent episode starts from the end of the previous one.

fillblanks

If not NULL, character used for filling gaps between episodes.

tmin

If sequences are to be defined on a calendar time axis, it defines the starting time of the axis. If set as NULL, the start time is set as the minimum of the 'begin' column in the data.

tmax

If year sequences are wanted, defines the ending year of the sequences. If set to NULL, it is guessed from the data (not so accurately!).

id

column containing the identification numbers for the sequences.

endObs

An optional end of observation date. Usefull for retrospective survey.

Details

Hortizontal spell data format has the following caracteristics: - One row per individual - Each spell is specified with three consecutive variables: a begin date, an end date, and the status. - For unused spells, begin and end values should be set as NA.

Value

A data.frame with the sequence in STS format.

Note

This function is a pre-release and further testing is still needed, please report any problems.

Author(s)

Matthias Studer

See Also

See Also seqformat.

Examples

hspell <- data.frame(begin1=rep(1, 5), end1=c(2:5, NA), status1=1:5,
                     begin2=c(3:6, NA), end2=rep(NA, 5), status2=5:1)
sts <- HSPELL_to_STS(hspell, begin=c("begin1", "begin2"), end=c("end1", "end2"),
                     status=c("status1", "status2"))

TraMineRextras documentation built on Sept. 11, 2024, 6:52 p.m.