Skip to contents

Creates a Force Directed Tree Chart for visualizing hierarchical data.

Usage

forceDirectedTree(data,
                  value_col="value",
                  attraction=-5, 
                  palette=c("#DD8D29","#E2D200","#46ACC8","#E58601","#B40F20"), 
                  col.n=9, 
                  show.link=TRUE, 
                  height=800,
                  width="100%",
                  max.radius=5,
                  elementId="chartdiv",
                  tooltip.text="{name}: {value}")

Arguments

data

An hierarchical data.frame to be converted in a json tree.

value_col

The name of the variable containing the frequency or the value to be represented. The default is "value".

attraction

The intensity of attraction among nodes. The default is -5.

palette

A color palette to be used to represent nodes. The default is NULL (the default would be "Dark2" from RColorBrewer).

col.n

The number of colors to represent. The default is 9.

show.link

Logical. Indicates that links connecting nodes will be made visible. The default is TRUE.

height

The height of the html panel in pixels. The default is 800.

width

The width of the html panel in pixels or percent. The default is 100%.

max.radius

The maximum radius of the nodes in percentage. The default is 5.

elementId

Name of the div element employed to contain the graph. It is useful when you use the same type of graph multiple times in the same markdown page, for instance. The default is "chartdiv".

tooltip.text

This option allows users to customize the text or html code that will be displayed on the tooltip of the chart. The default is "name: value".

Details

The function generates a Force Directed Tree Graph. It allows users to explore hierarchical data up to three levels.

Value

A Force Directed Tree chart or the html source code generated.

Examples

if (FALSE) {
# Create a test dataset
dt <- data.frame(
          Characters=c("Joao Grilo","Chico"), 
          Word.Type= c("Verb","Noun"), 
          Word=c("sing","harmonica"), 
          Frequency=c(2,3))
          
# Create the chart
forceDirectedTree(dt, value_col="Frequency")
}