R/seqstatf.R

Defines functions seqstatf

Documented in seqstatf

## =========================
## Sequences frequency table
## =========================

seqstatf <- function(seqdata, weighted=TRUE, with.missing=FALSE) {

	if (!is.stslist(seqdata))
		stop("data is not a sequence object, use seqdef function to create one")

	istatd <- suppressMessages(seqistatd(seqdata, with.missing=with.missing))

	## Weights
	weights <- attr(seqdata, "weights")

	if (!weighted || is.null(weights))
		weights <- rep(1, nrow(seqdata))

	istatd <- istatd*weights

	Freq <- colSums(istatd)

	Percent <- Freq/sum(Freq)*100

	res <- data.frame(Freq, Percent)

	return(res)

}

Try the TraMineR package in your browser

Any scripts or data that you put into this service are public.

TraMineR documentation built on Jan. 9, 2024, 3:02 p.m.