head.gtsummary: Display the first or last rows

View source: R/head.R

head.gtsummaryR Documentation

Display the first or last rows

Description

These functions allow you to view the first (head()) or last (tail()) n rows of a gtsummary table.

Usage

## S3 method for class 'gtsummary'
head(x, n = 6L, ...)

## S3 method for class 'gtsummary'
tail(x, n = 6L, ...)

Arguments

x

A gtsummary object.

n

Number of rows to return. Default is 6L as default in utils::head() and utils::tail().

...

Additional arguments passed to utils::head() or utils::tail().

Value

A gtsummary object with only the first or last n rows in table_body.

Examples

# head() example
trial |>
  tbl_summary(by = trt) |>
  head(n = 2L)

# tail() example
trial |>
  tbl_summary(by = trt) |>
  tail(n = 2L)


gtsummary documentation built on Aug. 26, 2026, 9:07 a.m.