Learn R Programming

treemapify (version 0.2.2)

treemapify: Generate coordinates for a treemap

Description

Takes a data frame of observations, with variables mapped to area and fill colour, and produces the coordinates for a treemap expressing these observations and mappings. These coordinates can be used to draw a customised treemap (recommended) or passed directly to the "ggplotify" function to produce an exploratory projection.

Input data frame must be in tidy format (see article by Hadley Wickham, below), i.e. each row must represent a single observation and each column a single variable. The area and fill parameters are mandatory; grouping and label factors are optional. Note that while adding a label will not change the treemap layout, adding a group will, as observations from the same group will be kept together.

Rect placement proceeds from the bottom left corner, alternating between moving rightwards and moving upwards. See Bruls et al. 1999 for the full algorithm.

Usage

treemapify(data, area, fill, group = FALSE, label = FALSE, xlim = c(0, 100), ylim = c(0, 100))

Arguments

data
a tidy data frame, containing at least variables to be mapped to area (size of rect) and fill (fill colour of rect).
area
variable to be mapped to area; must be a column in data
fill
variable to be mapped to fill; must be a column in data
group
(optional) variable to be mapped to group; must be a column in the data frame
label
(optional) variable to be used as the label for each observation; must be a column in the data frame
xlim,ylim
(optional) two-element vectors specifying the x and y limits of the area in which the rects will be placed

References

treemapify uses the Squarified Treemap algorithm of Mark Bruls, Kees Huizing and Jarke van Wijk:

Bruls, M., Huizing, K., & van Wijk, J. (1999). Squarified Treemaps (pp. 33-42). Presented at the In Proceedings of the Joint Eurographics and IEEE TCVG Symposium on Visualization.

http://www.win.tue.nl/~vanwijk/stm.pdf

"Tidy Data" is described by Hadley Wickham in an unpublished manuscript: http://vita.had.co.nz/papers/tidy-data.pdf

See Also

Other treemapify: ggplotify