hasse {hasseDiagram}R Documentation

Draw Hasse diagram

Description

This function draws Hasse diagram – visualization of transitive reduction of a finite partially ordered set.

Usage

hasse(data, labels = c(), parameters = list())

Arguments

data

n x n matrix, which represents partial order of n elements in set. Each cell [i, j] has value TRUE iff i-th element precedes j-th element.

labels

Vector containing labels of elements. If missing or NULL then data row names will be used as labels. If rownames(data) are not present, the labels will be generated as ('a' + element index).

parameters

List with named elements:

  • arrow – direction of arrows: "forward", "backward", "both" or "none" (default "forward"),

  • cluster – whether to cluster elements which have the same parents and children and are connected all to all (see first commented example) (default TRUE),

  • clusterMerge – merge clustered nodes within single node frame (default FALSE),

  • clusterNonAdjacent – to allow clustering elements that are not mutually adjacent (default FALSE),

  • edgeColor – edge color, from colors() (default "black"),

  • newpage – whether to call grid.newpage() before drawing (default TRUE),

  • nodeColor – node frame color, from colors() (default "black"),

  • margin – node margins, a list with 4 numerical items: "tb" for top-bottom margin, "rl" for right-left margin, "otb" and "orl" for outer margin when multiple labels are present,

  • shape – shape of diagram nodes: "roundrect", "rect" or "none" (default "roundrect"),

  • transitiveReduction – whether to perform transitive reduction (default TRUE).

Examples

randomData <- generateRandomData(15, 2, 0.5)
hasse(randomData)

# Clustering example
data <- matrix(data = FALSE, ncol = 4, nrow = 4)
data[1, 2] = data[1, 3] = data[2, 4] = data[3, 4] = TRUE
data[2, 3] = data[3, 2] = TRUE
hasse(data, c(), list(cluster = TRUE))
hasse(data, c(), list(cluster = FALSE))

# Hasse to pdf example
# randomData <- generateRandomData(15, 2, 0.5)
# pdf("path-for-diagram.pdf")
# hasse(randomData, NULL, list(newpage = FALSE))
# dev.off()

[Package hasseDiagram version 0.2.0 Index]