R/collapse_timeframes.R
collapse_timeframes.RdAllows users to take a high-resolution or continuous-time longitudinal
edgelist and dynamically collapse or discretize it into larger time windows.
The output is a shorter, aggregated edgelist ready to be passed into
[edgelist_to_adjmat] or [as_diffnet].
collapse_timeframes(
edgelist,
ego = "sender",
alter = "receiver",
timevar = "time",
weightvar = NULL,
window_size = 1,
time_format = NULL,
relative_time = TRUE,
binarize = FALSE,
cumulative = FALSE,
symmetric = FALSE
)A data.frame representing the longitudinal edgelist.
Character scalar. Name of the column representing the ego (sender).
Character scalar. Name of the column representing the alter (receiver).
Character scalar. Name of the column representing the time variable.
Character scalar or NULL. Name of the column representing
the edge weight. If NULL, the function tallies the number of interactions
within the time window as the weight.
Numeric scalar. The size of the time window to collapse into.
Character scalar or NULL. If the time variable is a
character or factor, the format passed to as.POSIXct.
For example, "%d-%m-%Y %H:%M".
Logical scalar. If TRUE, normalizes the binned
times into a strict integer sequence starting at 1 (1, 2, 3...).
Logical scalar. If TRUE, sets all resulting edge weights to 1.
Logical scalar. If TRUE, edges from previous time windows
are carried over to subsequent windows.
Logical scalar. If TRUE, the resulting graph will be
symmetrized (i.e., if an edge A->B exists, an edge B->A is added).
A data.frame with 4 columns: the ego, the alter, the new collapsed
discrete time, and the aggregated weight.
if (FALSE) { # \dontrun{
# Load the package's hourly dataset
load(system.file("data/epigames_raw.rda", package = "netdiffuseR"))
# Collapse the hourly edgelist into a daily edgelist (window_size = 24)
daily_edgelist <- collapse_timeframes(
edgelist = epigames_raw$edgelist,
timevar = "time",
weightvar = "weight",
window_size = 24
)
head(daily_edgelist)
} # }