connect_pairs | R Documentation |
Pairs, given as rows of a matrix
,
data.frame
, or list
, are processed to return
a list of paths, each identifying the connected pairs in the rows of x
.
connect_pairs(x, duplicate.rm = FALSE)
x |
two-column |
duplicate.rm |
|
A list
each of whose elements give a path of connected pairs.
Each list element is a vector of length at least 2
(longer vectors > 2 in length identify the pairs connected in a path).
Marius Hofert and Wayne Oldford
zenplot()
which provides the zenplot.
Other tools related to constructing zenpaths:
extract_pairs()
,
graph_pairs()
,
groupData()
,
indexData()
,
zenpath()
## First something simple.
(pairs <- matrix(c(1,2,2,3,3,5,5,7,8,9), ncol = 2, byrow = TRUE))
## Connect pairs into separate paths defined by the row order.
connect_pairs(pairs)
## Now something different
nVars <- 5
pairs <- expand.grid(1:nVars, 1:nVars)
## and take those where
(pairs <- pairs[pairs[,1] < pairs[,2],])
connect_pairs(pairs)
## Something more complicated.
## Get weights
set.seed(27135)
x <- runif(choose(nVars,2)) # weights
## We imagine pairs identify edges of a graph with these weights
## Get a zenpath ordering the edges based on weights
(zp <- zenpath(x, pairs = pairs, method = "strictly.weighted"))
## And connect these giving the list of paths
connect_pairs(zp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.