as.data.frame.dynet_collapsed_list: Tidy data frame of session-specific collapsed networks

View source: R/collapse.R

as.data.frame.dynet_collapsed_listR Documentation

Tidy data frame of session-specific collapsed networks

Description

Stacks the per-session edge tables into one tidy frame with a session key, so a session-separated collapse reads like every other verb's result. Without this the base method flattened the list sideways into a single row of s1.from, s2.from, ... columns.

Usage

## S3 method for class 'dynet_collapsed_list'
as.data.frame(x, row.names = NULL, optional = FALSE, session = NULL, ...)

Arguments

x

A dynet_collapsed_list from collapse_network(sessions = "separate").

row.names

Ignored; present for compatibility with the generic.

optional

Ignored; present for compatibility with the generic.

session

Optional session name. Supply one to get that session's table alone, without the session key; the default, NULL, stacks them all. A name that is not one of the collapsed sessions raises a dynet_unknown_session error.

...

Ignored.

Value

A plain data.frame, one row per collapsed pair per session, with session first and then the columns as.data.frame.dynet_collapsed() returns.

Examples

dn <- dynet(data.frame(
  from = c("A", "A"), to = c("B", "B"), start = c(0, 0), end = c(2, 3),
  session = c("s1", "s2")
), session = "session")
by_session <- collapse_network(dn, sessions = "separate")
as.data.frame(by_session)
as.data.frame(by_session, session = "s1")

Dynet documentation built on Oct. 7, 2026, 5:08 p.m.