Sequence index plots have been introduced by
scherer2001;textualggseqplot and display each sequence as
horizontally stacked bar or line. For a more detailed discussion of this
type of sequence visualization see, for example,
brzinsky-fay2014;textualggseqplot,
fasang2014;textualggseqplot,
and raab2022;textualggseqplot.
The function uses TraMineR::seqformat
to reshape seqdata stored in wide format into a spell/episode format.
Then the data are further reshaped into the long format, i.e. for
every sequence each row in the data represents one specific sequence
position. For example, if we have 5 sequences of length 10, the long file
will have 50 rows. In the case of sequences of unequal length not every
sequence will contribute the same number of rows to the long data.
The reshaped data are used as input for rendering the index plot using
ggplot2's geom_rect. ggseqiplot uses
geom_rect instead of geom_tile
because this allows for a straight forward implementation of weights.
If weights are specified for seqdata and weighted=TRUE
the sequence height corresponds to its weight.
If weights and a grouping variable are used, and facet_scale="fixed"
the values of the y-axis are not labeled, because
ggplot2 reasonably does not allow for varying scales
when the facet scale is fixed.
When a sortv is specified, the sequences are arranged in the order of
its values. With sortv="from.start" sequence data are sorted
according to the states of the alphabet in ascending order starting with the
first sequence position, drawing on succeeding positions in the case of
ties. Likewise, sortv="from.end" sorts a reversed version of the
sequence data, starting with the final sequence position turning to
preceding positions in case of ties.
Note that the default aspect ratio of ggseqiplot is different from
TraMineR::seqIplot. This is most obvious
when border=TRUE. You can change the ratio either by adding code to
ggseqiplot or by specifying the ratio when saving the code with
ggsave.