Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gt_preview

Preview a gt table object


Description

Sometimes you may want to see just a small portion of your input data. We can use gt_preview() in place of gt() to get the first x rows of data and the last y rows of data (which can be set by the top_n and bottom_n arguments). It's not advised to use additional gt functions to further modify the output of gt_preview(). Furthermore, you cannot pass a gt object to gt_preview().

Usage

gt_preview(data, top_n = 5, bottom_n = 1, incl_rownums = TRUE)

Arguments

data

A data.frame object or a tibble.

top_n

This value will be used as the number of rows from the top of the table to display. The default, 5, will show the first five rows of the table.

bottom_n

The value will be used as the number of rows from the bottom of the table to display. The default, 1, will show the final row of the table.

incl_rownums

An option to include the row numbers for data in the table stub. By default, this is TRUE.

Details

Any grouped data or magic columns such as rowname and groupname will be ignored by gt_preview() and, as such, one cannot add a stub or group rows in the output table. By default, the output table will include row numbers in a stub (including a range of row numbers for the omitted rows). This row numbering option can be deactivated by setting incl_rownums to FALSE.

Value

An object of class gt_tbl.

Figures

Function ID

1-2

See Also

Other Create Table: gt()

Examples

# Use `gtcars` to create a gt table
# preview (with only a few of its
# columns); you'll see the first five
# rows and the last row
tab_1 <-
  gtcars %>%
  dplyr::select(mfr, model, year) %>%
  gt_preview()

gt

Easily Create Presentation-Ready Display Tables

v0.2.2
MIT + file LICENSE
Authors
Richard Iannone [aut, cre] (<https://orcid.org/0000-0003-3925-190X>), Joe Cheng [aut], Barret Schloerke [aut] (<https://orcid.org/0000-0001-9986-114X>), RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.