Package 'blockr.gt'

Title: Create GT Tables in blockr
Description: This package provides an interface to the GT R package to create GT tables in blockr.
Authors: Michael Page [aut, cre]
Maintainer: Michael Page <[email protected]>
License: GPL (>= 3)
Version: 0.0.0.9000
Built: 2026-07-16 07:47:25 UTC
Source: https://github.com/cynkra/blockr.gt

Help Index


Create a new basic GT block

Description

Creates a new GT block with inputs for title, subtitle, and footnotes. This block provides an interface for a basic GT table.

Usage

new_basic_gt_block(
  title = character(),
  subtitle = character(),
  footnotes = character(),
  alignment = "center",
  ...
)

Arguments

title, subtitle, footnotes

Initial text for each field (character). All default to empty and accept markdown formatting.

alignment

The alignment of the title and subtitle elements in the table header.

...

Forwarded to blockr.core::new_block()

Value

A basic gt block object that can be used with the serve function.

Examples

## Not run: 
serve(new_basic_gt_block(title = "test"), data = list(data = head(mtcars)))

## End(Not run)

Color a gt block

Description

Color targeted cells in a GT block.

Usage

new_colour_gt_block(
  columns = numeric(),
  rows = character(),
  direction = character(),
  method = character(),
  palette = character(),
  bins = integer(),
  quantiles = integer(),
  alpha = numeric(),
  reverse = logical(),
  apply_to = character(),
  ...
)

Arguments

columns

The columns to which cell data color operations are constrained.

rows

In conjunction with columns, we can specify which rows should form a constraint for cell data color operations. Defaults to everything.

direction

Should the color computations be performed column-wise (default) or row-wise? Defeaults to colour down columns.

method

A method for computing color based on the data within body cells. Can be "auto" (the default), "numeric", "bin", "quantile", or "factor". The "auto" method will automatically choose the "numeric" method for numerical input data or the "factor" method for any non-numeric inputs.

palette

Name of the colour palette to use.

bins

Number of bins to use when method is "bin".

quantiles

Number of equal-sized quantiles to use when method is "quantile".

alpha

Transparency level for colors.

reverse

Logical indicating whether colors should be computed in reverse order.

apply_to

Whether colors should fill the cell background or the text.

...

Forwarded to blockr.core::new_block()

Value

A gt block with additional cell colouring.

Examples

## Not run: 
serve(new_colour_gt_block(), data = list(gt_obj = gt(head(mtcars))))

## End(Not run)

Save a gt table to multiple formats

Description

This block takes a gt table object and saves it to file in the specified format(s). Supports HTML, PDF, and PNG output formats.

Usage

new_save_gt_block(format = "pdf", expand = 10, ...)

Arguments

format

Vector of formats to save ("html", "pdf", "png")

expand

Numeric, expansion factor for PNG output (default 10)

...

Forwarded to blockr.core::new_block()

Value

Invisibly returns NULL, called for side effects

Examples

## Not run: 
serve(new_save_gt_block(), data = list(gt_obj = gt(mtcars)))

## End(Not run)

Add a spanner to a gt table

Description

Add a spanner to a gt table

Usage

new_spanner_gt_block(label = character(), columns = character(), ...)

Arguments

label

The text to use for the spanner label. Accepts markdown formatted text.

columns

The columns to serve as components of the spanner.

...

Forwarded to blockr.core::new_block()

Value

A gt block object with an added spanner.

Examples

## Not run: 
serve(new_spanner_gt_block(), data = list(gt_obj = gt(mtcars)))

## End(Not run)

Style a GT block

Description

Style a GT block using one of six prebuilt defaults with further options to control the table colour and row striping.

Usage

new_style_gt_block(style = 1, color = "gray", striping = "yes", ...)

Arguments

style

Numeric from 1 to 6 indicating which prebuilt default to use.

color

One of "blue", "cyan", "pink", "green", "red", and "gray".

striping

Logical indicating whether optional row striping should be enabled.

...

Forwarded to blockr.core::new_block()

Value

A styled gt block object that can be used with the serve function.

Examples

## Not run: 
serve(new_style_gt_block(), data = list(gt_obj = gt(head(mtcars))))

## End(Not run)