dyadic_to_multicast: Convert a dyadic event list to multicast format

View source: R/helpers.R

dyadic_to_multicastR Documentation

Convert a dyadic event list to multicast format

Description

This function converts a time-ordered event list in a dyadic edge-list style format with a 'from' column and a 'to' column into a multicast format as used by this package with receiver dummy variables after the from column. If the dyadic event list contains a column indicating the time or event ID, this can be specified to collect multiple simultaneous dyadic events spread across multiple rows into a single row in the multicast event list.

Usage

dyadic_to_multicast(
  event_list,
  from = 1,
  to = 2,
  time_col = NULL,
  char_names = NULL
)

Arguments

event_list

A time-ordered dyadic event list.

from

The numerical index of the 'from' column in event_list.

to

The numerical index of the 'to' column in event_list.

time_col

The numerical index of the column in event_list containing the event or time IDs. This is used to identify where multiple dyadic events are actually part of the same multicast interaction. If no such column exists, or all events are truly dyadic and sequential, the function will simply treat each row as an event.

char_names

An optional character vector of character names, ordered by character ID, used to label the columns.

Value

A time-ordered multicast event list as a matrix.

Examples

tfa <- movienetdata::starwars_tfa
# Convert The Force Awakens event list to dyadic format
tfa_dyads <- multicast_to_dyadic(tfa$event_list,
                                 from = 3)
# And convert it back to multicast format
tfa_events <- dyadic_to_multicast(event_list = tfa_dyads,
                                  from = 4,
                                  to = 5,
                                  time_col = 1,
                                  char_names = tfa$node_list$char_name)


pj398/charinet documentation built on May 2, 2024, 10:28 p.m.