path_counts: Count Path Frequencies in Trajectory Data

View source: R/mogen.R

path_countsR Documentation

Count Path Frequencies in Trajectory Data

Description

Counts the frequency of k-step paths (k-grams) across all trajectories. Useful for understanding which sequences dominate the data before applying formal models.

Usage

path_counts(data, k = 2L, top = NULL)

Arguments

data

A list of character vectors (trajectories) or a data.frame (rows = trajectories, columns = time points).

k

Integer. Length of the path / n-gram (default 2). A k of 2 counts individual transitions; k of 3 counts two-step paths, etc.

top

Integer or NULL. If set, returns only the top N most frequent paths (default NULL = all).

Value

A data frame with columns: path, count, proportion.

Examples

trajs <- list(c("A","B","C","D"), c("A","B","D","C"))
path_counts(trajs, k = 2)


path_counts(trajs, k = 3, top = 10)



Nestimate documentation built on April 20, 2026, 5:06 p.m.