Extracts pairs from a path of indices, representing the path by the pairs (connected by common variable) and return a shortened path.

extract_pairs(x, n)

Arguments

x

the path, a vector or list of indices of the variables to be plotted.

n

A vector of length two giving the number of pairs to extract from the path x (if NULL, all pairs are returned (nothing extracted); if of length one, it is replicated in the pair). The first number corresponds to the beginning of the path, the second to the end; at least one of the two numbers should be >= 1.

Value

returns an object of the same type as the input x but (possibly) shortened. It extracts the first/last so-many pairs of x.

See also

zenplot() which provides the zenplot.

Other tools related to constructing zenpaths: connect_pairs(), graph_pairs(), groupData(), indexData(), zenpath()

Author

Marius Hofert and Wayne Oldford

Examples

## Begin with a path
(zp <- zenpath(c(3, 5), method = "eulerian.cross")) # integer(2) argument
#>  [1] 1 4 2 5 1 6 2 7 1 8 3 4 3 6 7 3 5 8 2

## Extract the first two pairs and last four of indices
extract_pairs(zp, n = c(2, 4))
#> [1] 1 4 2 7 3 5 8 2

## Extract the first and last three pairs of indices
extract_pairs(zp, n = 3) # the 3 is repeated automatically
#> [1] 1 4 2 5 3 5 8 2