File: Quick_Introduction.R

package info (click to toggle)
r-cran-dendextend 1.14.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,888 kB
  • sloc: sh: 13; makefile: 2
file content (64 lines) | stat: -rw-r--r-- 1,880 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
## ---- echo = FALSE, message = FALSE, warning=FALSE----------------------------
library(dendextend)
library(knitr)
knitr::opts_chunk$set(
   cache = TRUE,
   dpi = 75,
   fig.width = 6, fig.height = 6,
  # comment = "#>",
  tidy = FALSE)

# https://stackoverflow.com/questions/24091735/why-pandoc-does-not-retrieve-the-image-file
# < ! -- rmarkdown v1 -->


## -----------------------------------------------------------------------------
library(dendextend) #

## -----------------------------------------------------------------------------
dend <- c(1:5) %>% dist %>% hclust("ave") %>% as.dendrogram

## -----------------------------------------------------------------------------
plot(dend)

## -----------------------------------------------------------------------------
labels(dend)
labels(dend) <- c("A", "B", "extend", "dend", "C")
labels(dend)

## -----------------------------------------------------------------------------
labels_colors(dend)
labels_colors(dend) <- rainbow(5)
labels_colors(dend)
plot(dend)

## -----------------------------------------------------------------------------
cutree(dend, k = 2)
dend <- color_branches(dend, k = 2)
plot(dend)

## -----------------------------------------------------------------------------
dend2 <- sort(dend)
plot(dend2)

## -----------------------------------------------------------------------------
tanglegram( dend,  dend2  )

## -----------------------------------------------------------------------------
cor_cophenetic( dend,  dend2  )

## -----------------------------------------------------------------------------
library(ggplot2)
ggplot(dend) 

## -----------------------------------------------------------------------------

# library(plotly)
# set_credentials_file(...) 
# you'll need to get it from here: https://plot.ly/ggplot2/getting-started/

# ggplot(dend)
# py <- plotly()
# py$ggplotly()