thin wrapper around mutate_weights() for the very common case of
"dichotomize the weighted network at a cut-point." returns a new
netify with edge values coerced to 0/1 based on the supplied
threshold (or threshold function).
Arguments
- netlet
a weighted netify object.
- threshold
numeric scalar (default
0– any nonzero edge becomes 1) or a functionf(x)that takes the vector of edge weights and returns a single numeric threshold (e.g.,function(x) median(x, na.rm = TRUE)orfunction(x) quantile(x, 0.75, na.rm = TRUE)). for longitudinal and multilayer networks, the function is evaluated once on the weights pooled across all periods and layers, and the resulting threshold is applied to every layer.- strict
logical. if
TRUE, edges with weight strictly greater than the threshold become 1; ifFALSE(default), the threshold itself is included (>=). forthreshold = 0, the default gives the "any nonzero edge counts" semantics that matches the rest of the package (signed-weight density, homophily-default-threshold, etc.).- abs
logical. if
TRUE, compare|x|to the threshold so that negative-magnitude ties also count toward the binarization. defaults toFALSE. when the network contains both positive and negative weights andabs = FALSE,binarize()informs once that negative ties will be dropped.- new_name
optional character. new name for the binarized weight column (default keeps the original name). for multilayer networks, supply one name per layer.
Details
na cells (e.g., the diagonal under diag_to_NA = TRUE)
propagate as na in the output rather than becoming 0. use
na.rm = TRUE when summing edges if you want them treated as 0.
structural zeros stay zero in every branch – a negative
threshold will not promote empty cells to 1, regardless of
strict or abs.
See also
mutate_weights() for arbitrary transformations.
Examples
# \donttest{
data(icews)
net <- netify(icews[icews$year == 2010, ],
actor1 = "i", actor2 = "j", symmetric = FALSE, weight = "verbCoop")
# any-nonzero-edge dichotomization
bin0 <- binarize(net)
#> ℹ network has been binarized through transformation
# 75th-percentile of nonzero weights
bin75 <- binarize(net, threshold = function(x) {
nz <- x[x > 0]
quantile(nz, 0.75, na.rm = TRUE)
})
#> ℹ network has been binarized through transformation
# }