Skip to contents

This function takes a data.frame and accumulates co-occurrences of codes within specified units and conversations (horizon), preparing it for ENA. It's designed to be used with pipes (`|>`)..

Usage

accumulate(
  x,
  units = rENA::units(x),
  codes = rENA::codes(x),
  horizon = rENA::horizon(x),
  ...,
  ordered = FALSE,
  binary = TRUE,
  weight_by = NULL,
  misses = TRUE,
  self_connections = FALSE
)

Arguments

x

A data.frame or similar object containing the data to be analyzed.

units

A character vector specifying the columns that define the units of analysis.

codes

A character vector specifying the columns that contain the codes for co-occurrence analysis.

horizon

A character vector specifying the columns that define the conversational boundaries (horizon).

...

Additional arguments passed to underlying accumulation functions.

ordered

A logical value. If TRUE, creates ordered networks (A -> B is different from B -> A). Defaults to FALSE.

binary

A logical value. If TRUE, each line's connection counts are binarized (0 or 1) before they are summed per unit (unordered networks; ordered counts are always summed raw). Defaults to TRUE. Ignored when `weight_by` is given.

weight_by

Weight model applied to each line's connection counts before they are summed into the unit network (the same stage as `weight.by` in `ena.accumulate.data()`): `"binary"`, `"product"` (the raw, non-binarized counts), `"sqrt"`, or `"log1p"` (alias `"log"`). For unordered networks the weight is applied after each line is folded to the upper triangle; for ordered networks, to each directed cell, and `"binary"` keeps the raw directed counts. Defaults to `"binary"` when `binary = TRUE`, otherwise `"product"`. Passed to [tma::accumulate()].

misses

A logical value. If TRUE (the default), also accumulate missed co-occurrences – for each line, the ground count of code i when code j is absent from the response – kept as `miss.counts` / `model$row.miss.counts` (and self-misses as `self.miss.counts`) alongside the connection counts; they are not used by the model. FALSE skips them (less memory for many codes or long data). Passed to [tma::accumulate()].

self_connections

A logical value, default FALSE. Unordered networks only: also include each code's self-connection (ground i -> response i, weighted per line like the other columns) as a connection column (A & A, A & B, B & B, ...), so normalization, rotation and node positions include it; nodes then count a self-connection `self_weight` times, as ordered models do (see [model()]). Ordered networks always include the diagonal. Passed to [tma::accumulate()].

Value

An ena.set object containing the accumulated connection counts and metadata.

Examples

data(RS.data)

codes <- c("Data", "Technical.Constraints", "Performance.Parameters",
           "Client.and.Consultant.Requests", "Design.Reasoning",
           "Collaboration")
units <- c("Condition", "UserName")
horizon <- c("Condition", "GroupName")
enaset <- RS.data |>
  accumulate(units, codes, horizon)

# square-root weighting of each line's co-occurrence counts
enaset_sqrt <- RS.data |>
  accumulate(units, codes, horizon, weight_by = "sqrt")