# How to find the rows that meet some conditions in a sequence data set

Here is the summary of my sequence data generated in the SPELL format. All sequences are supposed to have the same length of 1440, but the summary tells me that they are not the same (see "min/max sequence length:91/1440").

I want to find the rows:

1. that do not have the 1440 sequence length
2. that have missing states (*)
3. that have void elements (%)

Do you have any suggestions?

> summary(diary.seq)
[>] sequence object created with TraMineR version 1.8-3
[>] 4971 sequences in the data set, 4160 unique
[>] min/max sequence length: 91/1440
[>] alphabet (state labels):
1=Cr (Cr)
2=Ec (Ec)
3=Eo (Eo)
4=Hb (Hb)
5=Hc (Hc)
6=He (He)
7=Hr (Hr)
8=Hs (Hs)
9=Ir (Ir)
10=Lt (Lt)
11=Or (Or)
12=Pb (Pb)
...
[>] dimensionality of the sequence space: 27360
[>] colors: 1= 2= 3= 4= 5= 6= 7= 8= 9= 10= 11= 12= 13= 14= 15= 16= 17= 18= 19= 20=
[>] symbol for missing state: *
[>] symbol for void element: %


To select some sequences, you need to create a condition vector. For instance, you can select the sequences with a length lower than 1440 using the seqlength function. Here is an example with the "mvad" data set.

## Loading the library
library(TraMineR)
## Defining sequence properties
mvad.alphabet <- c("employment", "FE", "HE", "joblessness", "school", "training")
mvad.lab <- c("employment", "further education", "higher education", "joblessness", "school", "training")
mvad.shortlab <- c("EM", "FE", "HE", "JL", "SC", "TR")
## The state sequence object.


Now we can compute sequence length and build the vector (here all sequences have the same length of 70, so it does not make a lot of sense...). We used "<=" otherwise no sequences are selected, but in your case, you should use "<".

condition <- seqlength(mvad.seq) <= 70

state.count <- seqistatd(mvad.seq)