connect_pairs {zenplots} | R Documentation |
Connecting Possibly Overlapping Pairs Into a List of Paths
Description
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
.
Usage
connect_pairs(x, duplicate.rm = FALSE)
Arguments
x |
two-column |
duplicate.rm |
|
Value
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).
Author(s)
Marius Hofert and Wayne Oldford
See Also
zenplot()
which provides the zenplot.
Other tools related to constructing zenpaths:
extract_pairs()
,
graph_pairs()
,
groupData()
,
indexData()
,
zenpath()
Examples
## 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)
[Package zenplots version 1.0.6 Index]