vertex_covariate_compare | R Documentation |
Comparisons at dyadic level
vertex_covariate_compare(graph, X, funname)
graph |
A matrix of size |
X |
A numeric vector of length |
funname |
Character scalar. Comparison to make (see details). |
This auxiliary function takes advantage of the sparseness of graph
and
applies a function in the form of funname(x_i,x_j)
only to (i,j)
that have no empty entry. In other words, applies a compares
elements of X
only between vertices that have a link; making
nlinks(graph)
comparisons instead of looping through n\times n
,
which is much faster.
funname
can take any of the following values:
"distance"
, "^2"
or "quaddistance"
, ">"
or "greater"
,
"<"
or "smaller"
, ">="
or "greaterequal"
,
"<="
or "smallerequal"
, "=="
or "equal"
.
A matrix dgCMatrix
of size n\times n
with values in
the form of funname(x_i,x_j)
.
Other dyadic-level comparison functions:
matrix_compare()
,
vertex_covariate_dist()
# Basic example ------------------------------------------------------------
set.seed(1313)
G <- rgraph_ws(10, 4, .2)
x <- rnorm(10)
vertex_covariate_compare(G, x, "distance")
vertex_covariate_compare(G, x, "^2")
vertex_covariate_compare(G, x, ">=")
vertex_covariate_compare(G, x, "<=")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.