Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sortv

Sort sequences by states at the successive positions


Description

Returns a sorting vector to sort state sequences in a TraMineR sequence object (seqdef) by the states at the successive positions.

Usage

sorti(seqdata, start = "end", sort.index=TRUE)

sortv(seqdata, start = "end")

Arguments

seqdata

A state sequence object as returned by seqdef.

start

Where to start the sort. One of "beg" (beginning) or "end".

sort.index

Should the function return sort indexes? If FALSE, sort values are returned.

Details

With start = "end" (default), the primary sort key is the final state, then the previous one and so on. With start = "beg", the primary sort key is the state at the first position, then at the next one and so on.

With sort.index = FALSE, the function returns a vector of values whose order will determine the wanted order. This should be used as sortv argument of the seqiplot function. With sort.index = TRUE, the function returns a vector of indexes to be used for indexing.

The sortv form is an alias for sorti(..., sort.index = FALSE).

Value

If sort.index = FALSE, the vector of sorting values.
Otherwise the vector of sorting indexes.

Author(s)

Gilbert Ritschard

See Also

Details about type = "i" or type = "I" in seqplot .

Examples

data(actcal)
actcal.seq <- seqdef(actcal[1:100,13:24])
par(mfrow=c(1,2))
seqIplot(actcal.seq, sortv=sortv(actcal.seq), with.legend = FALSE)
seqIplot(actcal.seq, sortv=sortv(actcal.seq, start="beg"), with.legend = FALSE)
actcal.seq[sorti(actcal.seq)[90:100],]

data(mvad)
mvad.seq <- seqdef(mvad[1:100,17:86])
par(mfrow=c(1,2))
seqIplot(mvad.seq, sortv=sortv(mvad.seq, start="end"), with.legend = FALSE)
seqIplot(mvad.seq, sortv=sortv(mvad.seq, start="beg"), with.legend = FALSE)
print( mvad.seq[sorti(mvad.seq,start="beg")[90:100],], format="SPS")

TraMineRextras

TraMineR Extension

v0.6.1
GPL (>= 2)
Authors
Gilbert Ritschard [aut, cre, ths, cph] (<https://orcid.org/0000-0001-7776-0903>), Matthias Studer [aut] (<https://orcid.org/0000-0002-6269-1412>), Reto Buergin [aut], Tim Liao [ctb], Alexis Gabadinho [ctb], Pierre-Alexandre Fonta [ctb], Nicolas Muller [ctb], Patrick Rousset [ctb]
Initial release
2021-01-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.