adj_from_events: Extract an adjacency matrix from an event list

View source: R/helpers.R

adj_from_eventsR Documentation

Extract an adjacency matrix from an event list

Description

A helper function for extracting an adjacency matrix based on the interactions in an event list.

The event list should be structured consistently with the format specified elsewhere in this package documentation (at least a sender ID column followed by columns containing binary dummy variables for each character).

Usage

adj_from_events(event_list, char_names = NULL, from = 3, check_errors = FALSE)

Arguments

event_list

The event list, containing at least a sender ID column and columns containing binary dummy variables for each character.

char_names

An optional character vector containing node names used to label rows and columns in the adjacency matrix. If not provided, names are inferred from the event list.

from

The column containing the sender IDs, followed by dummy variables for each character.

check_errors

If TRUE, the function checks the event list for common data input errors. It looks for characters with self-ties, empty rows where no recipient was inputted, and any values other than 1 and 0 in the recipient dummy columns. Returns a message reporting the results of the checks.

Value

An adjacency matrix aggregated from interactions in an event list.

Examples

tfa <- movienetdata::starwars_tfa
tfa_adj <- adj_from_events(event_list = tfa$event_list,
                           char_names = tfa$node_list$char_name,
                           check_errors = TRUE)


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