| 1 |
# |
| 2 |
# ggdendro/R/dendro_tree.R by Andrie de Vries Copyright (C) 2011-2015 |
| 3 |
# |
| 4 |
# This program is free software; you can redistribute it and/or modify |
| 5 |
# it under the terms of the GNU General Public License as published by |
| 6 |
# the Free Software Foundation; either version 2 or 3 of the License |
| 7 |
# (at your option). |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# A copy of the GNU General Public License is available at |
| 15 |
# http://www.r-project.org/Licenses/ |
| 16 |
# |
| 17 |
# |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
# ------------------------------------------------------------------------ |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
#' Create Dendrograms and Tree Diagrams using 'ggplot2' |
| 26 |
#' |
| 27 |
#' This package enables you to create dendrograms and tree plots using |
| 28 |
#' [ggplot2::ggplot()]. |
| 29 |
#' |
| 30 |
#' The `ggplot2` philosophy is to clearly separate data from the presentation. |
| 31 |
#' Unfortunately the plot method for dendrograms ([plot.dendrogram()]) plots |
| 32 |
#' directly to a plot device without exposing the data. The `ggdendro` package |
| 33 |
#' resolves this by making available functions that extract the dendrogram plot |
| 34 |
#' data. This data can be used with `ggplot`. |
| 35 |
#' |
| 36 |
#' The function [dendro_data()] extracts data from different objects that |
| 37 |
#' contain dendrogram information. It is a generic function with methods for: |
| 38 |
#' |
| 39 |
#' - `hclust`: [dendro_data.hclust()] |
| 40 |
#' - dendrogram: [dendro_data.dendrogram()] |
| 41 |
#' - regression trees: [dendro_data.tree()] |
| 42 |
#' - partition trees: [dendro_data.rpart()] |
| 43 |
#' - `agnes` and `diana`: [dendro_data.twins()] |
| 44 |
#' |
| 45 |
#' These methods create an object of class `dendro`, consisting of a list of |
| 46 |
#' data frames. To extract the relevant data frames from the list, you can use |
| 47 |
#' the accessor functions: |
| 48 |
#' |
| 49 |
#' - [segment()]: the line segment data |
| 50 |
#' - [label()]: the text for each end segment |
| 51 |
#' - [leaf_label()]: the leaf labels of a tree diagram |
| 52 |
#' |
| 53 |
#' To plot a dendrogram, either construct a plot with [ggplot2::ggplot()] or use |
| 54 |
#' the function [ggdendrogram()]. |
| 55 |
#' |
| 56 |
#' @import MASS ggplot2 |
| 57 |
#' @importFrom grDevices col2rgb dev.cur dev.new |
| 58 |
#' @importFrom graphics par points polygon text |
| 59 |
#' @importFrom stats as.dendrogram complete.cases is.leaf |
| 60 |
#' @importFrom utils head stack tail |
| 61 |
#' @author Andrie de Vries - \email{apdevries@@gmail.com} |
| 62 |
#' @keywords package |
| 63 |
#' @seealso [dendro_data()] |
| 64 |
"_PACKAGE" |