- data
(data.frame) A data.frame with one column for each hierarchical level
- levels
(character) Character vector indicating the column names to
be used. The order of names must correspond to the hierarchical levels,
going from broad to fine
- fun
(function) Function to be used to aggregate cell sizes of parental cells
- sort
(logical) Should the columns of the data.frame be sorted before treemap generation?
- filter
(numeric) Filter the supplied data frame to remove very small
cells that may not be visible. The default is to remove cells with a
relative target area below a threshold of zero (no negative values allowed).
Computation time can increase when many small cells are present. For example,
a threshold of 0.01 filters out all observations/cells below 1 % of the total area.
- cell_size
(character) The name of the column used to control cell size.
Can be one of levels
or any other column with numerical data. NA or
values equal or less than zero are not allowed as the cell area needs to be positive.
The values in this column are aggregated by the function specified by fun
.
If cell_size = NULL
, cell area is simply computed by the number of members
for the respective cell (corresponding to rows in the data.frame).
- custom_color
(character) An optional column that can be specified to
control cell color. Cell colors are determined when drawing the treemap
using drawTreemap
, but the default is to use one of
levels
or cell size
. Any other data source that shall be used
instead has to be included in the treemap generation and explicitly
specified here. The default value is NULL
.
- shape
(list or character) Set the initial shape of the treemap. Currently
supported are the keywords "rectangle", "rounded_rect", "circle" or "hexagon".
Alternatively the user can supply a named list with coordinates for a custom polygon.
The slots of the list must be labeled 'x' and 'y'. The coordinates are not tested
for validity, use on your own risk.
- maxIteration
(numeric) Force algorithm to stop at this number of iterations
for each parent cell. The algorithm usually converges to an acceptable
solution fairly quickly, so it seems reasonable to restrict this number
in order to save computation time. However, more iterations give higher
accuracy.
- error_tol
(numeric) The allowed maximum error tolerance of a cell.
The algorithm will stop when all cells have lower error than this value.
It is calculated as the absolute difference of a cell's area to its target
area. The default is 0.01 (or 1 %) of the total parental area. Note: this
is is different from a relative per-cell error, where 1 % would be more
strict.
- convergence
(character) One of "slow", "intermediate", or "fast".
Intermediate (default) and fast try to adjust cell weights stronger such
that the algorithm converges faster towards the final size of the cell.
However this comes at the price of stability, with a larger number of
polygons possibly being misformed, e.g. by having self-intersections.
Set convergence to "slow" if you experience problems to calculate treemaps
with very unequal cell sizes or very large treemaps.
- seed
(integer) The default seed is NULL, which will lead to a new
random sampling of cell coordinates for each tesselation. If you want
a reproducible arrangement of cells, set seed to an arbitrary number.
- positioning
(character) Algorithm for positioning of starting
coordinates of child cells in the parental cell using spsample()
;
"random" for completely random positions, "regular" for cells aligned
to a grid sorted from bottom to top by name, "clustered" with regular
positions of cells but sorted by name from inside out. Two variants
"regular_by_area" and "clustered_by_area" will work as their counterparts
but will sort by cell target area instead of cell name. positioning
can be a single character or a vector of length(levels)
to allow
different positioning algorithms for each level.
- verbose
(logical) If verbose is TRUE (default is FALSE), messages
with statistics for each iteration of a treemap as well as a success message
are printed to the console.
- debug
(logical) If debug is TRUE (default is FALSE), the solution
for each iteration is drawn to the viewport to allow some visual
inspection. The weights, target area, and difference are printed to the
console. It is not recommended to set this option to TRUE unless you know
what you are doing, as it makes treemap generation much slower.