state_distribution: Per-Class State Distribution as a Tidy Data Frame

View source: R/plot_state_frequencies.R

state_distributionR Documentation

Per-Class State Distribution as a Tidy Data Frame

Description

Returns a tidy data.frame(group, state, count, proportion) with one row per (group, state) cell. Companion to state_frequencies (which counts unique states in raw sequence input); state_distribution() pulls the same shape of frame from a fitted Nestimate object so analyses don't have to reach for the underlying $data slot directly.

Usage

state_distribution(x, ...)

## S3 method for class 'netobject'
state_distribution(x, ...)

## S3 method for class 'htna'
state_distribution(x, ...)

## S3 method for class 'mcml'
state_distribution(x, include_macro = FALSE, ...)

## S3 method for class 'netobject_group'
state_distribution(x, ...)

## Default S3 method:
state_distribution(x, ...)

Arguments

x

A netobject, netobject_group, mcml, or htna object.

...

Currently unused.

include_macro

For mcml: when TRUE, prepend a group = "macro" block aggregating across clusters. Ignored for the other classes.

Details

Used internally by plot_state_frequencies as the data layer behind every chart, and surfaced as the $table slot of the returned state_freq object.

Value

A data.frame with columns group (character), state (character), count (integer), and proportion (numeric, within-group share).

Examples

## Not run: 
  data(ai_long)
  net <- build_network(ai_long, method = "frequency",
                       id_col = "session_id",
                       time_col = "order_in_session", action = "code")
  state_distribution(net)

## End(Not run)

Nestimate documentation built on July 11, 2026, 1:09 a.m.