View source: R/seqmaintokens.R
| seqmaintokens | R Documentation |
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.
seqmaintokens(seqdata, k=8L, mint=NULL, ...)
seqdata |
state sequence |
k |
Integer. Number of main states. |
mint |
Real. Minimal mean number of occurrences per sequence. |
... |
Additional arguments passed to |
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.
Vector of indexes of the most frequent tokens repecting order of the alphabet.
Gilbert Ritschard
seqmeant
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"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.