remidpoint: Set dendrogram attributes for a nested list.

Description Usage Arguments Value Author(s) Examples

View source: R/utils.R

Description

remidpoint is a helper function used for manually creating "dendrogram" objects from nested lists. The function recursively assigns the necessary 'midpoint', 'members', and 'leaf' attributes at each node.

Usage

1

Arguments

x

a nested list, possibly of class "dendrogram"

Value

returns a nested list, or an object of class "dendrogram" depending on the class of the input object.

Author(s)

Shaun Wilkinson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
  ## manually create a small dendrogram with three members, A, B and C
  x <- list("A", list("B", "C"))
  attr(x[[1]], "leaf") <- TRUE
  attr(x[[2]][[1]], "leaf") <- TRUE
  attr(x[[2]][[2]], "leaf") <- TRUE
  attr(x[[1]], "label") <- "A"
  attr(x[[2]][[1]], "label") <- "B"
  attr(x[[2]][[2]], "label") <- "C"
  attr(x, "height") <- 1
  attr(x[[1]], "height") <- 0
  attr(x[[2]], "height") <- 0.5
  attr(x[[2]][[1]], "height") <- 0
  attr(x[[2]][[2]], "height") <- 0
  x <- remidpoint(x)
  class(x) <- "dendrogram"
  plot(x, horiz = TRUE)

shaunpwilkinson/phylogram documentation built on Dec. 11, 2019, 11:36 p.m.