Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

hasse

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 NULL names of rows of parameter data will be used or labels will be generated ('a' + element index) in case rownames(data) is NULL.

parameters

List with named elements:

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

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

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

  • shape – shape of diagram nodes: "roundrect" or "rect" (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()

hasseDiagram

Drawing Hasse Diagram

v0.1.3
MIT + file LICENSE
Authors
Krzysztof Ciomek
Initial release
2017-02-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.