as_cascade_long {NetworkInference} | R Documentation |
Transform long data to cascade
Description
Create a cascade object from data in long format.
Usage
as_cascade_long(data, cascade_node_name = "node_name",
event_time = "event_time", cascade_id = "cascade_id",
node_names = NULL)
Arguments
data |
data.frame, containing the cascade data
with column names corresponding to the arguments provided to
|
cascade_node_name |
character, column name of |
event_time |
character, column name of |
cascade_id |
character, column name of the cascade identifier. |
node_names |
character, factor or numeric vector containing the names for each node. Optional. If not provided, node names are inferred from the cascade data. |
Details
Each row of the data describes one event in the cascade. The data must contain at least three columns:
Cascade node name: The identifier of the node that experiences the event.
Event time: The time when the node experiences the event. 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()'.
Cascade id: The identifier of the cascade that the event pertains to.
The default names for these columns are node_name
, event_time
and cascade_id
. If other names are used in the data
object the
names have to be specified in the corresponding arguments (see argument
documentation)
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
df <- simulate_rnd_cascades(10, n_nodes = 20)
cascades <- as_cascade_long(df)
is.cascade(cascades)