random.hierarchical.data: Create random hierarchical data

View source: R/random_hierarchical_data.R

random.hierarchical.dataR Documentation

Create random hierarchical data

Description

This function generates random hierarchical data. Experimental.

Usage

random.hierarchical.data(
  n = NULL,
  method = "random",
  number.children = 3,
  children.root = 4,
  depth = 3,
  nodes.per.layer = NULL,
  labels = c("LETTERS", "numbers", "letters"),
  labels.prefix = NULL,
  sep = ".",
  colnames = c(paste("index", 1:depth, sep = ""), "x"),
  value.generator = rlnorm,
  value.generator.args = NULL
)

Arguments

n

number of leaf nodes. This is a shortcut argument. If specified, the method is set to "random.arcs" with a nodes.per.layer such that the average number of children per layer is as constant as possible.

method

one of

"random":

Random tree where for each node, the number of children, is determined by a random poisson generator with lambda=number.children, until the maximum depth specified by depth is reached. The number of children of the root node is set to children.root.

"random.arcs":

Random tree where the exact number of nodes in each layer must be speficied by nodes.per.layer. The arcs between the layers are random, with the restriction that each node is connected.

"full.tree":

Each node has exactly number.children children.

number.children

the number of children. For method="random" this is the average number of children and for method="full.tree", it is the exact number of children. In the latter case, it can also be a vector that specifies the number of children for each layer.

children.root

number of children of the root node. For method="random" only.

depth

depth of the tree. Note that for method="random", this depth may not be reached.

nodes.per.layer

exact number of nodes per layer, that is needed for method="random.arcs"

labels

one of "letters", "LETTERS", "numbers", "numbers1", "numbers0", "hex", "bits". The label set for "numbers1" is 1:9, and for "numbers0" it is 0:9. "numbers" is equal to "numbers0", except that is starts from 1.

labels.prefix

vector of label prefixes, one for each layer

sep

seperator character

colnames

names of the columns. The first depth columns are the index columns (from highest to lowest hierarchical layer), and the last column is stored with random values

value.generator

function that determine the random values for the leaf nodes

value.generator.args

list of arguments passed to value.generator

Examples

d <- random.hierarchical.data(200)
treemap(d, index=names(d)[1:(ncol(d)-1)], vSize="x")

d <- random.hierarchical.data(number.children=5)
treemap(d, index=names(d)[1:(ncol(d)-1)], vSize="x")

d <- random.hierarchical.data(method="full.tree", number.children=3, value.generator=runif)
treemap(d, index=names(d)[1:(ncol(d)-1)], vSize="x")

treemap documentation built on May 31, 2023, 8:01 p.m.