as_cascade_wide {NetworkInference} | R Documentation |
Transform wide data to cascade
Description
Create a cascade object from data in wide format.
Usage
as_cascade_wide(data, node_names = NULL)
Arguments
data |
data.frame or matrix, rows corresponding to nodes, columns to cascades. Matrix entries are the event times for each node, cascade pair. Missing values indicate censored observations, that is, nodes that did not have an event). Specify column and row names if cascade and node ids other than integer sequences are desired. Note that, if the time column is of class date or any other special time class, it will be converted to an integer with 'as.numeric()'. |
node_names |
character, factor or numeric vector, containing names for each node. Optional. If not provided, node names are inferred from the provided data. |
Details
If data is in wide format, each row corresponds to a node and each column to
a cascade. Each cell indicates the event time for a node - cascade
combination. If a node did not experience an event for a cascade (the node
is censored) the cell entry must be NA
.
Value
An object of class cascade
. This is a list containing three
(named) elements:
-
"node_names"
A character vector of node names. -
"cascade_nodes"
A list with one character vector per cascade containing the node names in order of the events. -
"cascade_times"
A list with one element per cascade containing the event times for the nodes in"cascade_names"
.
Examples
data("policies")
cascades <- as_cascade_long(policies, cascade_node_name = 'statenam',
event_time = 'adopt_year', cascade_id = 'policy')
wide_policies = as.matrix(cascades)
cascades <- as_cascade_wide(wide_policies)
is.cascade(cascades)