Learn R Programming

dendextend (version 1.13.4)

as.phylo.dendrogram: Convert a dendrogram into phylo

Description

Based on as.hclust.dendrogram with as.phylo.hclust

In the future I hope a more direct link will be made.

Usage

as.phylo.dendrogram(x, ...)

Arguments

x

a dendrogram

...

ignored.

Value

A phylo class object

See Also

as.dendrogram, as.hclust, as.phylo

Examples

Run this code
# NOT RUN {
library(dendextend)
library(ape)
dend <- iris[1:30, -5] %>%
  dist() %>%
  hclust() %>%
  as.dendrogram()
dend2 <- as.phylo(dend)
plot(dend2, type = "fan")


# Also possible to with ggplot2 :)

library(dendextend)
library(ggplot2)
library(ggdendro)
dend <- iris[1:30, -5] %>%
  dist() %>%
  hclust() %>%
  as.dendrogram()
# Rectangular lines
ddata <- dend %>% dendro_data(type = "rectangle")
p <- ggplot(segment(ddata)) +
  geom_segment(aes(x = x, y = y, xend = xend, yend = yend)) +
  coord_flip() +
  scale_y_reverse(expand = c(0.2, 0)) + coord_polar(theta = "x")
p
# }
# NOT RUN {

# see: https://github.com/klutometis/roxygen/issues/796
#
# }

Run the code above in your browser using DataLab