Learn R Programming

phylogram (version 1.0.0)

write.dendrogram: Export a dendrogram object to text.

Description

This function writes a dendrogram object to Newick-style parenthetic text.

Usage

write.dendrogram(x, file = "", append = FALSE, edges = TRUE, ...)

Arguments

x

an object of class "dendrogram".

file

a character string naming a file or connection to write the output to. If no file path is specified or file = "" the result is printed to the console.

append

logical indicating whether the output should be appended to the file. If append = FALSE the contents of the file will be overwritten (the default setting).

edges

logical indicating whether edge weights should be included in the output string.

...

further arguments to be passed to format. Used to specify the numbering style of the edge weights (if edges = TRUE).

See Also

read.dendrogram to create a "dendrogram" object from a text file. The write.tree function in the ape package performs a similar operation for "phylo" and "multiPhylo" objects.

Examples

Run this code
  ## build and export tree for the woodmouse data (ape package)
  library(ape)
  data(woodmouse)
  ## trim gappy ends for global alignment
  woodmouse <- woodmouse[, apply(woodmouse, 2, function(v) !any(v == 0xf0))]
  ## build topdown tree
  set.seed(999)
  x <- topdown(woodmouse, nstart = 20)
  write.dendrogram(x, edges = TRUE)

Run the code above in your browser using DataLab