Create a cascade object from data in long format.
as_cascade_long(data, cascade_node_name = "node_name",
event_time = "event_time", cascade_id = "cascade_id",
node_names = NULL)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".
data.frame, containing the cascade data
with column names corresponding to the arguments provided to
cascade_node_names, event_time and cascade_id.
character, column name of data that specifies
the node names in the cascade.
character, column name of data that specifies the
event times for each node involved in a cascade.
character, column name of the cascade identifier.
character, factor or numeric vector containing the names for each node. Optional. If not provided, node names are inferred from the cascade data.
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)
df <- simulate_rnd_cascades(10, n_nodes = 20)
cascades <- as_cascade_long(df)
is.cascade(cascades)
Run the code above in your browser using DataLab