seqmaintokens: Indexes of most frequent tokens

View source: R/seqmaintokens.R

seqmaintokensR Documentation

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, ...)

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

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.

Value

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

Author(s)

Gilbert Ritschard

See Also

seqmeant

Examples

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"

TraMineR documentation built on Dec. 8, 2024, 3:01 p.m.