visNetwork (version 2.0.3)

visHclust: Visualize Hierarchical cluster analysis.

Description

Visualize Hierarchical cluster analysis hclust. This function compute distance using dist, and Hierarchical cluster analysis using hclust (from stats package or flashClust if installed), and render the tree with visNetwork, adding informations. Can also be called on a hclust or dist object. Needed packages : shiny, sparkline (graphics on tooltip), ggraph, igraph, flashClust

Usage

visHclust(object, ...)

# S3 method for default visHclust(object, ...)

# S3 method for data.frame visHclust(object, main = "", submain = "", footer = "", distColumns = NULL, distMethod = "euclidean", hclustMethod = "complete", cutree = 0, tooltipColumns = 1:ncol(object), colorEdges = "black", colorGroups = substr(rainbow(cutree), 1, 7), highlightNearest = TRUE, minNodeSize = 50, maxNodeSize = 200, nodesPopSize = TRUE, height = "600px", width = "100%", export = TRUE, ...)

# S3 method for dist visHclust(object, data = NULL, main = "", submain = "", footer = "", cutree = 0, hclustMethod = "complete", tooltipColumns = if (!is.null(data)) { 1:ncol(data) } else { NULL }, colorEdges = "black", colorGroups = substr(rainbow(cutree), 1, 7), highlightNearest = TRUE, minNodeSize = 50, maxNodeSize = 200, nodesPopSize = TRUE, height = "600px", width = "100%", export = TRUE, ...)

# S3 method for hclust visHclust(object, data = NULL, main = "", submain = "", footer = "", cutree = 0, tooltipColumns = if (!is.null(data)) { 1:ncol(data) } else { NULL }, colorEdges = "black", colorGroups = substr(rainbow(cutree), 1, 7), highlightNearest = TRUE, minNodeSize = 50, maxNodeSize = 200, nodesPopSize = TRUE, height = "600px", width = "100%", export = TRUE, ...)

Arguments

object

hclust | dist | data.frame.

...

Nothing

main

For add a title. See visNetwork

submain

For add a subtitle. See visNetwork

footer

For add a footer. See visNetwork

distColumns

numeric indice of columns used for compute distance. If NULL (default), keep all numeric and integer columns. If Not NULL, we keep only numeric and integer columns

distMethod

character the distance measure to be used for dist function. Default to 'euclidean'. See dist.

hclustMethod

character the agglomeration method to be used for hclust function. Default to 'complete'. See hclust.

cutree

numeric or integer desired number of groups. Default to 0

tooltipColumns

numeric indice of columns used in tooltip. All by default. So, we add a boxplot or a pie focus on sub-population and all population using sparkline package.

colorEdges

character color of edges. Default to 'black'

colorGroups

character, color for group in exa ("#00FF00"). Default rainbow.

highlightNearest

boolean highlight sub-tree on click.

minNodeSize

numeric, in case of nodesPopSize, minimum size of a node. Defaut to 15. Else, nodes size is minNodeSize + maxNodeSize / 2

maxNodeSize

numeric, in case of nodesPopSize, maximum size of a node. Defaut to 30. Else, nodes size is minNodeSize + maxNodeSize / 2

nodesPopSize

boolean, nodes sizes depends on population ? Default to FALSE

height

character, default to "600px"

width

character, default to "100%"

export

boolean, add button for export. Default to TRUE

data

data.frame data.frame with data. Only for hclust or dist object.

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
#--------------
# data.frame
#--------------

# default call on data.frame
visHclust(iris, cutree = 3, colorEdges = "red")

# update some parameters
visHclust(iris, cutree = 3,
  tooltipColumns = c(1, 5),
  colorGroups = c("red", "blue", "green"))
  
# no graphics on tooltip
visHclust(iris, cutree = 3,
  tooltipColumns = NULL,
  main = "Hclust on iris")
  
# update group / individual nodes
visHclust(iris, cutree = 8) %>% 
 visGroups(groupname = "group", color ="#00FF00", shape = "square")  %>% 
 visGroups(groupname = "individual", color ="#FF0000")

#--------------
# dist
#--------------

# without adding data & info in tooltip
visHclust(dist(iris[,1:4]), cutree = 3)
  
# adding data & info in tooltip
visHclust(dist(iris[,1:4]), cutree = 3, 
    data = iris)

#--------------
# hclust
#--------------

# without adding data & info in tooltip
visHclust(hclust(dist(iris[,1:4])), cutree = 3)
  
# adding data & info in tooltip
visHclust(hclust(dist(iris[,1:4])), cutree = 3, 
    data = iris) 
  
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace