Skip to contents

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:

  • categorical and multiple_response generate a bar chart frequency tile.

  • categorical_array generates a card with subvariable totals.

  • numeric generates a histogram.

  • text generates 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 CROSSTAB where supported.

tile_width

Tile width. Default is 6.

tile_height

Tile height. Default is 4.

Value

A single character scalar containing Crunch dashboard tile DSL.

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:

  • categorical

  • multiple_response

  • categorical_array (grouping ignored)

  • numeric (grouping ignored)

  • text