Generates Crunch dashboard DSL for a single variable, handling common Crunch variable types and optionally splitting results by a grouping variable.
Usage
crunch_generate_tile(
alias,
name,
type,
description,
weight_var = NULL,
palette = "Gradient",
axis_position = "INSIDE",
group_by = NULL,
tile_width = 6,
tile_height = 4
)Arguments
- alias
Variable alias in the Crunch dataset.
- name
Display name for the tile.
- type
Crunch variable type. Valid types:
categoricalandmultiple_responsegenerate a bar chart frequency tile.categorical_arraygenerates a card with subvariable totals.numericgenerates a histogram.textgenerates a table of counts.
- description
Variable description (used as subtitle).
- weight_var
Optional weighting variable alias. If
NULL, tile is unweighted.- palette
Palette name to use. Must be a single character string. Currently:
"Gradient"or"CZI".- axis_position
Position of category axis.
"INSIDE"or"LEFT".- group_by
Optional grouping variable alias. If supplied, results are split using
CROSSTABwhere supported.- tile_width
Tile width. Default is
6.- tile_height
Tile height. Default is
4.
Details
When group_by is provided, the function switches to CROSSTAB only
for supported types. Grouping is silently ignored where Crunch does not
support it (e.g. numeric histograms, categorical arrays).
Supported types:
categoricalmultiple_responsecategorical_array(grouping ignored)numeric(grouping ignored)text