Skip to contents

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)
Characteristic Drug A
N = 98
1
Drug B
N = 102
1
Age 46 (37, 60) 48 (39, 56)
    Unknown 7 4
1 Median (Q1, Q3); n (%)
# tail() example trial |> tbl_summary(by = trt) |> tail(n = 2L)
Characteristic Drug A
N = 98
1
Drug B
N = 102
1
Patient Died 52 (53%) 60 (59%)
Months to Death/Censor 23.5 (17.4, 24.0) 21.2 (14.5, 24.0)
1 Median (Q1, Q3); n (%)