Learn R Programming

TraMineR (version 2.2-10)

seqmaintokens: Indexes of most frequent tokens

Description

Extracts the indexes of the most frequent token, either the k most frequent tokens or the tokens that occur on average more than mint times.

Usage

seqmaintokens(seqdata, k=8L, mint=NULL, ...)

Value

Vector of indexes of the most frequent tokens repecting order of the alphabet.

Arguments

seqdata

state sequence stslist object as produced by seqdef.

k

Integer. Number of main states.

mint

Real. Minimal mean number of occurrences per sequence.

...

Additional arguments passed to seqmeant

Author

Gilbert Ritschard

Details

When mint is NULL, indexes of the k most frequent tokens. Otherwise, indexes of tokens occurring on average more than tmin times are returned as long as their number does not exceed k. If more than k, indexes of the k most frequent are returned.

See Also

seqmeant

Examples

Run this code
data(biofam)
b.lab <- c("Parent",
           "Left",
           "Married",
           "Left+Marr",
           "Child",
           "Left+Child",
           "Left+Marr+Child",
           "Divorced"
)
b.short <- c("P","L","M","L+M","C","L+C","L+M+C","D")
set.seed(5)
cases <- sample(nrow(biofam),100)
b.seq <- seqdef(biofam[cases,10:25], labels=b.lab, states=b.short,
                weights=biofam[cases,"wp00tbgs"])

## Tokens occurring at least once on average
alphabet(b.seq)[seqmaintokens(b.seq, mint=1)]
#[1] "P"     "L"     "L+M"   "L+M+C"

## Three more frequent tokens
main.tokens <- seqmaintokens(b.seq, k=3)
## Labels of main tokens
attr(b.seq,"labels")[main.tokens]
#[1] "Parent"  "Left"    "Left+Marr+Child"
## Colors of main tokens
cpal(b.seq)[main.tokens]
#[1] "#7FC97F" "#BEAED4" "#BF5B17"

Run the code above in your browser using DataLab