Learn R Programming

TraMineRextras (version 0.2.2)

seqgranularity: Changing sequence time granularity by aggregating positions

Description

Changes time granularity of a state sequence object by aggregating successive positions into groups of a user-defined time length.

Usage

seqgranularity(seqdata, tspan = 3, method = "last")

Arguments

seqdata
A state sequence object.
tspan
Integer. Number of successive positions grouped together.
method
Character string. Aggregating method. One of "first" or "last" (default).

Value

  • The resulting state sequence object.

Warning

This function needs further testing.

Details

Successive position are aggregated by group of tspan, starting from the first position and, with method "last", the last state in the group is assigned to the group. In case of an incomplete last group, the last state is assigned to it.

See Also

seqdef

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

data(mvad)
mvad <- mvad[1:100,]
mvad.seq <- seqdef(mvad[,17:86], xtstep=12)
mvadg.seq <- seqgranularity(mvad.seq, tspan=6)
par(mfrow=c(2,1))
seqdplot(mvad.seq, withlegend=FALSE, border=NA)
seqdplot(mvadg.seq, withlegend=FALSE)

Run the code above in your browser using DataLab