seqpd prints the sequence data in one of four layouts, chosen
by layout (TDA's m=):
- 1
every sequence structure side by side, one row per case
- 2
one row per case and structure
- 3
one row per case, structure and position
- 4
one row per spell: its origin and destination state, and the times it spans
Arguments
- sequences
a data frame or matrix of one column per time point, in order, the same shape
tda_seqmtakes – optionally with further, non-sequence columns (an id, say) alongside them; usevariables/idto say which is which rather than pre-subsettingsequencesyourself.- layout
1 to 4, the shape of the result, as listed above.
- select
optional expression (
sel=) restricting which sequences are used – written with R's comparison operators (Y0 == 1, orY0 = 1) or TDA's function form (eq(Y0,1)) interchangeably;&/|combine several conditions the same way in both.- variables
which columns of
sequencesare the actual time-point columns, in order – TDA'sseqdef=Y0,,Y7, which likewise names the sequence out of a data matrix holding other variables too rather than requiring them to be dropped first. A character vector of names insequences; defaults to every column (so passing an already-subsettedsequencesstill works exactly as before).- id
further columns of
sequencesto carry through to the output as-is, one value per case –seqgc/seqlg/seqpm/seqsi'sv=, which writes the case's raw value onto its output row, no more. A character vector of names insequences.seqsdandseqenhave no per-case row to attach a value to (one row per time point, over all cases) and error if given one – TDA acceptsv=there without complaint but never actually writes the column.- options
a named list of further TDA options, passed through.
- type
the sequence data type, TDA's
seqdefm=:1(default) one column per time point,2columns read as state/time pairs, one pair per spell, with the time axis taken from the times rather than from the column count.- second
names of the columns of a second sequence structure, declared beside the first as the manual's
seq5.cfdoes; the tables then carry one column per structure.- second_type
the sequence data type of the second structure, as
type; default 2, state/time pairs.- dir
working directory.
- ...
passed to
tda_run.
Examples
# four cases over three states, one sequence structure
s <- data.frame(ID = 1:4,
Y1 = c(1, 2, 3, 1), Y2 = c(1, 2, 3, 3),
Y3 = c(2, 2, 1, 3), Y4 = c(2, 3, 1, 1))
tda_seqpd(s, id = "ID")
#> case y0_0 y0_1 y0_2 y0_3 id
#> 1 1 1 1 2 2 1
#> 2 2 2 2 2 3 2
#> 3 3 3 3 1 1 3
#> 4 4 1 3 3 1 4
# one row per spell instead, with the times each spans
tda_seqpd(s, layout = 4, id = "ID")
#> case sn org des ts tf id
#> 1 1 1 1 2 0 2 1
#> 2 1 2 2 2 2 4 1
#> 3 2 1 2 3 0 3 2
#> 4 2 2 3 3 3 4 2
#> 5 3 1 3 1 0 2 3
#> 6 3 2 1 1 2 4 3
#> 7 4 1 1 3 0 1 4
#> 8 4 2 3 1 1 3 4
#> 9 4 3 1 1 3 4 4